🎨 Rebuilding database block relations when importing .sy.zip and rebuilding indexes https://github.com/siyuan-note/siyuan/issues/10959
This commit is contained in:
parent
c4d2f9e706
commit
7d680ed391
2 changed files with 13 additions and 0 deletions
|
@ -281,6 +281,10 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
|
|||
}
|
||||
return ast.WalkContinue
|
||||
})
|
||||
|
||||
// 关联数据库和块
|
||||
avNodes := tree.Root.ChildrenByType(ast.NodeAttributeView)
|
||||
av.BatchUpsertBlockRel(avNodes)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue