mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
🐛 删除父文档时子文档排序配置未清理干净 Fix https://github.com/siyuan-note/siyuan/issues/6469
This commit is contained in:
parent
43ae47a902
commit
0b1e48c24a
2 changed files with 4 additions and 24 deletions
|
|
@ -1226,11 +1226,12 @@ func removeDoc(box *Box, p string) (err error) {
|
||||||
|
|
||||||
copyDocAssetsToDataAssets(box.ID, p)
|
copyDocAssetsToDataAssets(box.ID, p)
|
||||||
|
|
||||||
rootID := tree.ID
|
|
||||||
var removeIDs []string
|
var removeIDs []string
|
||||||
removeIDs = append(removeIDs, rootID)
|
ids := rootChildIDs(tree.ID)
|
||||||
|
removeIDs = append(removeIDs, ids...)
|
||||||
|
|
||||||
dir := path.Dir(p)
|
dir := path.Dir(p)
|
||||||
childrenDir := path.Join(dir, rootID)
|
childrenDir := path.Join(dir, tree.ID)
|
||||||
existChildren := box.Exist(childrenDir)
|
existChildren := box.Exist(childrenDir)
|
||||||
if existChildren {
|
if existChildren {
|
||||||
absChildrenDir := filepath.Join(util.DataDir, tree.Box, childrenDir)
|
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())
|
indexHistoryDir(filepath.Base(historyDir), NewLute())
|
||||||
|
|
||||||
if existChildren {
|
if existChildren {
|
||||||
ids := util.GetChildDocIDs(filepath.Join(util.DataDir, tree.Box, childrenDir))
|
|
||||||
removeIDs = append(removeIDs, ids...)
|
|
||||||
if err = box.Remove(childrenDir); nil != err {
|
if err = box.Remove(childrenDir); nil != err {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -202,22 +202,3 @@ func FilterSelfChildDocs(paths []string) (ret []string) {
|
||||||
}
|
}
|
||||||
return
|
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
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue