From 0b1e48c24aa442a500790f5657315e53fed96103 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 3 Nov 2022 20:23:24 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E5=88=A0=E9=99=A4=E7=88=B6=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E6=97=B6=E5=AD=90=E6=96=87=E6=A1=A3=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=9C=AA=E6=B8=85=E7=90=86=E5=B9=B2=E5=87=80?= =?UTF-8?q?=20Fix=20https://github.com/siyuan-note/siyuan/issues/6469?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/file.go | 9 ++++----- kernel/util/path.go | 19 ------------------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/kernel/model/file.go b/kernel/model/file.go index b76449eaa..67c775cf9 100644 --- a/kernel/model/file.go +++ b/kernel/model/file.go @@ -1226,11 +1226,12 @@ func removeDoc(box *Box, p string) (err error) { copyDocAssetsToDataAssets(box.ID, p) - rootID := tree.ID var removeIDs []string - removeIDs = append(removeIDs, rootID) + ids := rootChildIDs(tree.ID) + removeIDs = append(removeIDs, ids...) + dir := path.Dir(p) - childrenDir := path.Join(dir, rootID) + childrenDir := path.Join(dir, tree.ID) existChildren := box.Exist(childrenDir) if existChildren { 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()) if existChildren { - ids := util.GetChildDocIDs(filepath.Join(util.DataDir, tree.Box, childrenDir)) - removeIDs = append(removeIDs, ids...) if err = box.Remove(childrenDir); nil != err { return } diff --git a/kernel/util/path.go b/kernel/util/path.go index 7249ab72a..54dad6677 100644 --- a/kernel/util/path.go +++ b/kernel/util/path.go @@ -202,22 +202,3 @@ func FilterSelfChildDocs(paths []string) (ret []string) { } 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 -}