Skip to content

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

:bug: 删除父文档时子文档排序配置未清理干净 Fix https://github.com/siyuan-note/siyuan/issues/6469

Liang Ding0b1e48c24aa4
diff --git a/kernel/model/file.go b/kernel/model/file.go
index b76449eaaa..67c775cf9c 100644
--- a/kernel/model/file.go
+++ b/kernel/model/file.go
@@ -1226,11 +1226,12 @@ func removeDoc(box *Box, p string) (err error) {
copyDocAssetsToDataAssets(box.ID, p)
- rootID := tree.ID
var removeIDs []string
- removeIDs = append(removeIDs, rootID)
+ ids := rootChildIDs(tree.ID)
+ removeIDs = append(removeIDs, ids...)
+
dir := path.Dir(p)
- childrenDir := path.Join(dir, rootID)
+ childrenDir := path.Join(dir, tree.ID)
existChildren := box.Exist(childrenDir)
if existChildren {
absChildrenDir := filepath.Join(util.DataDir, tree.Box, childrenDir)
@@ -1242,8 +1243,6 @@ func removeDoc(box *Box, p string) (err error) {
indexHistoryDir(filepath.Base(historyDir), NewLute())
if existChildren {
- ids := util.GetChildDocIDs(filepath.Join(util.DataDir, tree.Box, childrenDir))
- removeIDs = append(removeIDs, ids...)
if err = box.Remove(childrenDir); nil != err {
return
}
diff --git a/kernel/util/path.go b/kernel/util/path.go
index 7249ab72a2..54dad66771 100644
--- a/kernel/util/path.go
+++ b/kernel/util/path.go
@@ -202,22 +202,3 @@ func FilterSelfChildDocs(paths []string) (ret []string) {
}
return
}
-
-func GetChildDocIDs(parentDocDirAbsPath string) (ret []string) {
- if !gulu.File.IsDir(parentDocDirAbsPath) {
- return
- }
-
- filepath.Walk(parentDocDirAbsPath, func(p string, info os.FileInfo, err error) error {
- if info.IsDir() {
- return nil
- }
- if !strings.HasSuffix(p, ".sy") {
- return nil
- }
- id := strings.TrimSuffix(filepath.Base(p), ".sy")
- ret = append(ret, id)
- return nil
- })
- return
-}