Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:zap: Improve performance for API getBlockTreeInfos

Daniele490b6e1f690
diff --git a/kernel/model/block.go b/kernel/model/block.go
index 5b59475ab7..bfc2951480 100644
--- a/kernel/model/block.go
+++ b/kernel/model/block.go
@@ -130,26 +130,8 @@ type BlockTreeInfo struct {
func GetBlockTreeInfos(ids []string) (ret map[string]*BlockTreeInfo) {
ret = map[string]*BlockTreeInfo{}
- luteEngine := util.NewLute()
- treeCache := map[string]*parse.Tree{}
- for _, id := range ids {
- bt := treenode.GetBlockTree(id)
- if nil == bt {
- ret[id] = &BlockTreeInfo{ID: id}
- continue
- }
-
- tree := treeCache[bt.RootID]
- if nil == tree {
- tree, _ = filesys.LoadTree(bt.BoxID, bt.Path, luteEngine)
- if nil == tree {
- ret[id] = &BlockTreeInfo{ID: id}
- continue
- }
-
- treeCache[bt.RootID] = tree
- }
-
+ trees := filesys.LoadTrees(ids)
+ for id, tree := range trees {
node := treenode.GetNodeInTree(tree, id)
if nil == node {
ret[id] = &BlockTreeInfo{ID: id}