Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve move doc https://github.com/siyuan-note/siyuan/issues/9356

Daniel9e731908e24f
diff --git a/kernel/model/file.go b/kernel/model/file.go
index e49ebcbe9f..69663ff2a1 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