An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:zap: Improve performance for batch set block attrs
Daniel4f07f3314aa7
diff --git a/kernel/model/blockial.go b/kernel/model/blockial.goindex e136407dc0..a712fe5514 100644--- a/kernel/model/blockial.go+++ b/kernel/model/blockial.go@@ -28,6 +28,7 @@ import ("github.com/88250/lute/parse""github.com/araddon/dateparse""github.com/siyuan-note/siyuan/kernel/cache"+ "github.com/siyuan-note/siyuan/kernel/filesys""github.com/siyuan-note/siyuan/kernel/sql""github.com/siyuan-note/siyuan/kernel/treenode""github.com/siyuan-note/siyuan/kernel/util"@@ -101,31 +102,21 @@ func BatchSetBlockAttrs(blockAttrs []map[string]interface{}) (err error) {}WaitForWritingFiles()- trees := map[string]*parse.Tree{}- for _, blockAttr := range blockAttrs {- id := blockAttr["id"].(string)- bt := treenode.GetBlockTree(id)- if nil == bt {- return errors.New(fmt.Sprintf(Conf.Language(15), id))- }- if nil == trees[bt.RootID] {- tree, e := LoadTreeByBlockID(id)- if nil != e {- return e- }- trees[bt.RootID] = tree- }+ var blockIDs []string+ for _, blockAttr := range blockAttrs {+ blockIDs = append(blockIDs, blockAttr["id"].(string))}+ trees := filesys.LoadTrees(blockIDs)var nodes []*ast.Nodefor _, blockAttr := range blockAttrs {id := blockAttr["id"].(string)- bt := treenode.GetBlockTree(id)- if nil == bt {+ tree := trees[id]+ if nil == tree {return errors.New(fmt.Sprintf(Conf.Language(15), id))}- tree := trees[bt.RootID]+node := treenode.GetNodeInTree(tree, id)if nil == node {return errors.New(fmt.Sprintf(Conf.Language(15), id))