mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-02 23:29:27 +08:00
🐛 删除父文档时子文档排序配置未清理干净 Fix https://github.com/siyuan-note/siyuan/issues/6469
This commit is contained in:
parent
0e651b097f
commit
43ae47a902
@ -1241,16 +1241,17 @@ func removeDoc(box *Box, p string) (err error) {
|
||||
}
|
||||
indexHistoryDir(filepath.Base(historyDir), NewLute())
|
||||
|
||||
box.removeSort(rootID, p)
|
||||
if existChildren {
|
||||
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
|
||||
}
|
||||
|
||||
if existChildren {
|
||||
box.Remove(childrenDir)
|
||||
ids := util.GetChildDocIDs(filepath.Join(util.DataDir, tree.Box, childrenDir))
|
||||
removeIDs = append(removeIDs, ids...)
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user