From 9e731908e24fcfa1ab7896c1b2b3c29b862219b8 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 15 Mar 2024 23:36:46 +0800 Subject: [PATCH] :art: Improve move doc https://github.com/siyuan-note/siyuan/issues/9356 --- kernel/model/file.go | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/kernel/model/file.go b/kernel/model/file.go index e49ebcbe9..69663ff2a 100644 --- a/kernel/model/file.go +++ b/kernel/model/file.go @@ -1257,8 +1257,12 @@ func MoveDocs(fromPaths []string, toBoxID, toPath string, callback interface{}) } } - // A progress layer appears when moving more than 16 documents at once https://github.com/siyuan-note/siyuan/issues/9356 - needShowProgress := 16 < len(fromPaths) + // A progress layer appears when moving more than 64 documents at once https://github.com/siyuan-note/siyuan/issues/9356 + subDocsCount := 0 + for fromPath, fromBox := range pathsBoxes { + subDocsCount += countSubDocs(fromBox.ID, fromPath) + } + needShowProgress := 64 < subDocsCount if needShowProgress { defer util.PushClearProgress() } @@ -1282,6 +1286,23 @@ func MoveDocs(fromPaths []string, toBoxID, toPath string, callback interface{}) return } +func countSubDocs(box, p string) (ret int) { + p = strings.TrimSuffix(p, ".sy") + _ = filepath.Walk(filepath.Join(util.DataDir, box, p), func(path string, info os.FileInfo, err error) error { + if nil != err { + return err + } + if info.IsDir() { + return nil + } + if strings.HasSuffix(path, ".sy") { + ret++ + } + return nil + }) + return +} + func moveDoc(fromBox *Box, fromPath string, toBox *Box, toPath string, luteEngine *lute.Lute, callback interface{}) (newPath string, err error) { isSameBox := fromBox.ID == toBox.ID