🎨 子文档缺失父文档时自动补全 https://github.com/siyuan-note/siyuan/issues/7376

This commit is contained in:
Liang Ding 2023-02-16 09:29:10 +08:00
parent 0f6b4bd395
commit 326945d4b6
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 24 additions and 0 deletions

View file

@ -82,11 +82,13 @@ func LoadTreeByData(data []byte, boxID, p string, luteEngine *lute.Lute) (ret *p
parentData, readErr := filelock.ReadFile(parentAbsPath)
if nil != readErr {
if os.IsNotExist(readErr) {
// 子文档缺失父文档时自动补全 https://github.com/siyuan-note/siyuan/issues/7376
parentTree := treenode.NewTree(boxID, parentPath, hPathBuilder.String()+"Untitled", "Untitled")
if writeErr := WriteTree(parentTree); nil != writeErr {
logging.LogErrorf("rebuild parent tree [%s] failed: %s", parentAbsPath, writeErr)
} else {
logging.LogInfof("rebuilt parent tree [%s]", parentAbsPath)
treenode.IndexBlockTree(parentTree)
}
} else {
logging.LogWarnf("read parent tree data [%s] failed: %s", parentAbsPath, readErr)