diff --git a/kernel/model/import.go b/kernel/model/import.go index 641e0cea1..938cf00e9 100644 --- a/kernel/model/import.go +++ b/kernel/model/import.go @@ -281,6 +281,10 @@ func ImportSY(zipPath, boxID, toPath string) (err error) { } return ast.WalkContinue }) + + // 关联数据库和块 + avNodes := tree.Root.ChildrenByType(ast.NodeAttributeView) + av.BatchUpsertBlockRel(avNodes) } } diff --git a/kernel/model/index.go b/kernel/model/index.go index 710f77330..3a325368a 100644 --- a/kernel/model/index.go +++ b/kernel/model/index.go @@ -36,6 +36,7 @@ import ( "github.com/siyuan-note/eventbus" "github.com/siyuan-note/filelock" "github.com/siyuan-note/logging" + "github.com/siyuan-note/siyuan/kernel/av" "github.com/siyuan-note/siyuan/kernel/cache" "github.com/siyuan-note/siyuan/kernel/filesys" "github.com/siyuan-note/siyuan/kernel/sql" @@ -143,6 +144,7 @@ func index(boxID string) { poolSize = 4 } waitGroup := &sync.WaitGroup{} + var avNodes []*ast.Node p, _ := ants.NewPoolWithFunc(poolSize, func(arg interface{}) { defer waitGroup.Done() @@ -168,6 +170,10 @@ func index(boxID string) { } } + lock.Lock() + avNodes = append(avNodes, tree.Root.ChildrenByType(ast.NodeAttributeView)...) + lock.Unlock() + cache.PutDocIAL(file.path, docIAL) treenode.IndexBlockTree(tree) sql.IndexTreeQueue(tree) @@ -191,6 +197,9 @@ func index(boxID string) { waitGroup.Wait() p.Release() + // 关联数据库和块 + av.BatchUpsertBlockRel(avNodes) + box.UpdateHistoryGenerated() // 初始化历史生成时间为当前时间 end := time.Now() elapsed := end.Sub(start).Seconds()