🎨 子文档缺失父文档时自动补全 https://github.com/siyuan-note/siyuan/issues/7376

This commit is contained in:
Liang Ding 2023-02-16 09:29:10 +08:00
parent 0f6b4bd395
commit 326945d4b6
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 24 additions and 0 deletions

View file

@ -128,9 +128,26 @@ func resetDuplicateBlocksOnFileSys() {
boxPath := filepath.Join(util.DataDir, box.ID)
filepath.Walk(boxPath, func(path string, info os.FileInfo, err error) error {
if info.IsDir() {
if boxPath == path {
// 跳过根路径(笔记本文件夹)
return nil
}
if strings.HasPrefix(info.Name(), ".") {
return filepath.SkipDir
}
if !ast.IsNodeIDPattern(info.Name()) {
return nil
}
if util.IsEmptyDir(filepath.Join(path)) {
// 删除空的子文档文件夹
if removeErr := os.RemoveAll(path); nil != removeErr {
logging.LogErrorf("remove empty folder failed: %s", removeErr)
}
return nil
}
return nil
}
@ -234,6 +251,11 @@ func fixBlockTreeByFileSys() {
boxPath := filepath.Join(util.DataDir, box.ID)
var paths []string
filepath.Walk(boxPath, func(path string, info os.FileInfo, err error) error {
if boxPath == path {
// 跳过根路径(笔记本文件夹)
return nil
}
if info.IsDir() {
if strings.HasPrefix(info.Name(), ".") {
return filepath.SkipDir