🎨 改进移动文档路径过滤

This commit is contained in:
Liang Ding 2022-11-05 22:59:24 +08:00
parent 1708fb091a
commit 538b0b36a9
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 18 additions and 2 deletions

View file

@ -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], "/") })