Skip to content

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

:zap: 改进重建索引 https://github.com/siyuan-note/siyuan/issues/7018

Liang Ding07a5e7501a8f
diff --git a/kernel/filesys/tree.go b/kernel/filesys/tree.go
index 916efa5ce7..c539db0ad2 100644
--- a/kernel/filesys/tree.go
+++ b/kernel/filesys/tree.go
@@ -29,6 +29,7 @@ import (
"github.com/88250/lute"
"github.com/88250/lute/parse"
"github.com/88250/lute/render"
+ jsoniter "github.com/json-iterator/go"
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/cache"
@@ -88,13 +89,13 @@ func LoadTree(boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err erro
hPathBuilder.WriteString("Untitled/")
continue
}
- parentTree, parseErr := parse.ParseJSONWithoutFix(parentData, luteEngine.ParseOptions)
- if nil != parseErr {
- logging.LogWarnf("parse parent tree [%s] failed: %s", parentAbsPath, parseErr)
- hPathBuilder.WriteString("Untitled/")
- continue
+
+ ial := ReadDocIAL(parentData)
+ title := ial["title"]
+ if "" == title {
+ title = "Untitled"
}
- hPathBuilder.WriteString(parentTree.Root.IALAttr("title"))
+ hPathBuilder.WriteString(title)
hPathBuilder.WriteString("/")
}
hPathBuilder.WriteString(ret.Root.IALAttr("title"))
@@ -262,3 +263,9 @@ func parseJSON2Tree(boxID, p string, jsonData []byte, luteEngine *lute.Lute) (re
}
return
}
+
+func ReadDocIAL(data []byte) (ret map[string]string) {
+ ret = map[string]string{}
+ jsoniter.Get(data, "Properties").ToVal(&ret)
+ return
+}
diff --git a/kernel/model/file.go b/kernel/model/file.go
index 9c885effd4..165569ebdb 100644
--- a/kernel/model/file.go
+++ b/kernel/model/file.go
@@ -37,7 +37,6 @@ import (
"github.com/dustin/go-humanize"
"github.com/facette/natsort"
"github.com/gin-gonic/gin"
- jsoniter "github.com/json-iterator/go"
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/cache"
@@ -143,7 +142,7 @@ func (box *Box) docIAL(p string) (ret map[string]string) {
logging.LogErrorf("read file [%s] failed: %s", p, err)
return nil
}
- ret = readDocIAL(data)
+ ret = filesys.ReadDocIAL(data)
if 1 > len(ret) {
logging.LogWarnf("tree [%s] is corrupted", filePath)
box.moveCorruptedData(filePath)
@@ -167,12 +166,6 @@ func (box *Box) moveCorruptedData(filePath string) {
logging.LogWarnf("moved corrupted data file [%s] to [%s]", filePath, to)
}
-func readDocIAL(data []byte) (ret map[string]string) {
- ret = map[string]string{}
- jsoniter.Get(data, "Properties").ToVal(&ret)
- return
-}
-
func SearchDocsByKeyword(keyword string) (ret []map[string]string) {
ret = []map[string]string{}