An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Add a kernel API `/api/block/getDocsInfo` https://github.com/siyuan-note/siyuan/pull/12723 https://github.com/siyuan-note/siyuan/issues/12740
Daniel7028759499b9
diff --git a/kernel/filesys/tree.go b/kernel/filesys/tree.goindex 77ba47d744..654521b76c 100644--- a/kernel/filesys/tree.go+++ b/kernel/filesys/tree.go@@ -43,18 +43,19 @@ func LoadTrees(ids []string) (ret map[string]*parse.Tree) {luteEngine := util.NewLute()var boxIDs []stringvar paths []string- seen := make(map[string]bool)+ blockIDs := map[string]string{}+ seen := map[string]bool{}for _, bt := range bts {key := bt.BoxID + bt.Pathif !seen[key] {seen[key] = trueboxIDs = append(boxIDs, bt.BoxID)paths = append(paths, bt.Path)+ blockIDs[bt.RootID] = bt.ID}}- trees, errs := BatchLoadTrees(boxIDs, paths, luteEngine)-+ trees, errs := batchLoadTrees(boxIDs, paths, luteEngine)for i := range trees {tree := trees[i]err := errs[i]@@ -63,7 +64,8 @@ func LoadTrees(ids []string) (ret map[string]*parse.Tree) {continue}- ret[tree.ID] = tree+ id := blockIDs[tree.Root.ID]+ ret[id] = tree}return}@@ -80,11 +82,9 @@ func LoadTree(boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err erroreturn}-func BatchLoadTrees(boxIDs, paths []string, luteEngine *lute.Lute) ([]*parse.Tree, []error) {- results := make([]*parse.Tree, len(paths))- errs := make([]error, len(paths))-+func batchLoadTrees(boxIDs, paths []string, luteEngine *lute.Lute) (ret []*parse.Tree, errs []error) {var wg sync.WaitGroup+ lock := sync.Mutex{}for i := range paths {wg.Add(1)go func(i int) {@@ -93,13 +93,14 @@ func BatchLoadTrees(boxIDs, paths []string, luteEngine *lute.Lute) ([]*parse.TreboxID := boxIDs[i]path := paths[i]tree, err := LoadTree(boxID, path, luteEngine)- results[i] = tree- errs[i] = err+ lock.Lock()+ ret = append(ret, tree)+ errs = append(errs, err)+ lock.Unlock()}(i)}wg.Wait()-- return results, errs+ return}func LoadTreeByData(data []byte, boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err error) {