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

This commit is contained in:
Liang Ding 2022-11-03 20:25:56 +08:00
parent 0b1e48c24a
commit 21e354836e
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 27 additions and 26 deletions

View file

@ -19,7 +19,9 @@ package treenode
import (
"crypto/sha256"
"fmt"
"io/fs"
"path"
"path/filepath"
"sort"
"strings"
@ -108,3 +110,26 @@ func IALStr(n *ast.Node) string {
}
return string(parse.IAL2Tokens(n.KramdownIAL))
}
func RootChildIDs(rootID string) (ret []string) {
root := GetBlockTree(rootID)
if nil == root {
return
}
ret = append(ret, rootID)
boxLocalPath := filepath.Join(util.DataDir, root.BoxID)
subFolder := filepath.Join(boxLocalPath, strings.TrimSuffix(root.Path, ".sy"))
if !gulu.File.IsDir(subFolder) {
return
}
filepath.Walk(subFolder, func(path string, info fs.FileInfo, err error) error {
if strings.HasSuffix(path, ".sy") {
name := filepath.Base(path)
id := strings.TrimSuffix(name, ".sy")
ret = append(ret, id)
}
return nil
})
return
}