🎨 改进内核任务调度机制提升稳定性 https://github.com/siyuan-note/siyuan/issues/7113

This commit is contained in:
Liang Ding 2023-01-23 18:44:19 +08:00
parent 72093f7e2e
commit a452015ded
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
3 changed files with 5 additions and 25 deletions

View file

@ -393,7 +393,7 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
continue
}
treenode.IndexBlockTree(tree)
treenode.ReindexBlockTree(tree)
sql.UpsertTreeQueue(tree)
}

View file

@ -86,11 +86,13 @@ func index(boxID string) {
updated := util.TimeFromID(tree.Root.ID)
tree.Root.SetIALAttr("updated", updated)
docIAL["updated"] = updated
writeJSONQueue(tree)
if writeErr := filesys.WriteTree(tree); nil != writeErr {
logging.LogErrorf("write tree [%s] failed: %s", tree.Path, writeErr)
}
}
cache.PutDocIAL(file.path, docIAL)
treenode.IndexBlockTree(tree)
treenode.ReindexBlockTree(tree)
sql.UpsertTreeQueue(tree)
util.IncBootProgress(bootProgressPart, fmt.Sprintf(Conf.Language(92), util.ShortPathForBootingDisplay(tree.Path)))

View file

@ -320,28 +320,6 @@ func ReindexBlockTree(tree *parse.Tree) {
blockTreesChanged = true
}
func IndexBlockTree(tree *parse.Tree) {
blockTreesLock.Lock()
defer blockTreesLock.Unlock()
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering || !n.IsBlock() {
return ast.WalkContinue
}
var parentID string
if nil != n.Parent {
parentID = n.Parent.ID
}
if "" == n.ID {
return ast.WalkContinue
}
blockTrees[n.ID] = &BlockTree{ID: n.ID, ParentID: parentID, RootID: tree.ID, BoxID: tree.Box, Path: tree.Path, HPath: tree.HPath, Updated: tree.Root.IALAttr("updated")}
return ast.WalkContinue
})
// 新建索引不变更持久化文件,调用处会负责调用 SaveBlockTree()
}
func AutoFlushBlockTree() {
for {
SaveBlockTree(false)