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: 删除父文档时子文档排序配置未清理干净 Fix https://github.com/siyuan-note/siyuan/issues/6469
Liang Ding43ae47a902b1
diff --git a/kernel/model/file.go b/kernel/model/file.goindex 3a990bea9e..b76449eaaa 100644--- a/kernel/model/file.go+++ b/kernel/model/file.go@@ -1241,16 +1241,17 @@ func removeDoc(box *Box, p string) (err error) {}indexHistoryDir(filepath.Base(historyDir), NewLute())- box.removeSort(rootID, p)- if err = box.Remove(p); nil != err {- return- }-if existChildren {- box.Remove(childrenDir)ids := util.GetChildDocIDs(filepath.Join(util.DataDir, tree.Box, childrenDir))removeIDs = append(removeIDs, ids...)+ if err = box.Remove(childrenDir); nil != err {+ return+ }+ }+ if err = box.Remove(p); nil != err {+ return}+ box.removeSort(removeIDs)treenode.RemoveBlockTreesByPathPrefix(childrenDir)sql.RemoveTreePathQueue(box.ID, childrenDir)@@ -1659,30 +1660,7 @@ func (box *Box) fillSort(files *[]*File) {}}-func (box *Box) removeSort(rootID, path string) {- absRoot := filepath.Join(util.DataDir, box.ID, path)- absRootDir := strings.TrimSuffix(absRoot, ".sy")- toRemoves := map[string]bool{rootID: true}- filepath.Walk(absRootDir, func(path string, info fs.FileInfo, err error) error {- if nil == info {- return nil- }- name := info.Name()- isDir := info.IsDir()- if util.IsReservedFilename(name) {- if isDir {- return filepath.SkipDir- }- return nil- }-- if !isDir && strings.HasSuffix(name, ".sy") {- id := strings.TrimSuffix(name, ".sy")- toRemoves[id] = true- }- return nil- })-+func (box *Box) removeSort(ids []string) {confPath := filepath.Join(util.DataDir, box.ID, ".siyuan", "sort.json")if !gulu.File.IsExist(confPath) {return@@ -1700,7 +1678,7 @@ func (box *Box) removeSort(rootID, path string) {return}- for toRemove := range toRemoves {+ for _, toRemove := range ids {delete(fullSortIDs, toRemove)}diff --git a/kernel/util/path.go b/kernel/util/path.goindex 26ece4a0ba..7249ab72a2 100644--- a/kernel/util/path.go+++ b/kernel/util/path.go@@ -208,14 +208,14 @@ func GetChildDocIDs(parentDocDirAbsPath string) (ret []string) {return}- filepath.Walk(parentDocDirAbsPath, func(path string, info os.FileInfo, err error) error {+ filepath.Walk(parentDocDirAbsPath, func(p string, info os.FileInfo, err error) error {if info.IsDir() {return nil}- if !strings.HasSuffix(path, ".sy") {+ if !strings.HasSuffix(p, ".sy") {return nil}- id := path[len(parentDocDirAbsPath)+1 : len(path)-3]+ id := strings.TrimSuffix(filepath.Base(p), ".sy")ret = append(ret, id)return nil})