From 538b0b36a9e3b73624be0a6f6c8f175a0229638d Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sat, 5 Nov 2022 22:59:24 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=94=B9=E8=BF=9B=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E8=B7=AF=E5=BE=84=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/file.go | 8 ++++++-- kernel/util/path.go | 12 ++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/kernel/model/file.go b/kernel/model/file.go index 33773fb2f..ab5259684 100644 --- a/kernel/model/file.go +++ b/kernel/model/file.go @@ -1012,7 +1012,11 @@ func MoveDocs(fromPaths []string, toBoxID, toPath string) (err error) { return } - fromPaths = util.FilterSelfChildDocs(fromPaths) + fromPaths = util.FilterMoveDocFromPaths(fromPaths, toPath) + if 1 > len(fromPaths) { + return + } + pathsBoxes := getBoxesByPaths(fromPaths) // 检查路径深度是否超过限制 @@ -1024,7 +1028,7 @@ func MoveDocs(fromPaths []string, toBoxID, toPath string) (err error) { } } - needShowProgress := 32 < len(fromPaths) + needShowProgress := 16 < len(fromPaths) if needShowProgress { util.PushEndlessProgress(Conf.Language(116)) } diff --git a/kernel/util/path.go b/kernel/util/path.go index 722018f75..741e8354a 100644 --- a/kernel/util/path.go +++ b/kernel/util/path.go @@ -175,6 +175,18 @@ func NormalizeEndpoint(endpoint string) string { return endpoint } +func FilterMoveDocFromPaths(fromPaths []string, toPath string) (ret []string) { + tmp := FilterSelfChildDocs(fromPaths) + for _, fromPath := range tmp { + fromDir := strings.TrimSuffix(fromPath, ".sy") + if strings.HasPrefix(toPath, fromDir) { + continue + } + ret = append(ret, fromPath) + } + return +} + func FilterSelfChildDocs(paths []string) (ret []string) { sort.Slice(paths, func(i, j int) bool { return strings.Count(paths[i], "/") < strings.Count(paths[j], "/") })