This commit is contained in:
Liang Ding 2022-11-04 15:35:22 +08:00
parent 89166ca0d5
commit 75925c9e4f
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 25 additions and 10 deletions

View file

@ -178,11 +178,12 @@ func NormalizeEndpoint(endpoint string) string {
func FilterMoveDocFromPaths(fromPaths []string, toPath string) (retFromPaths []string) {
fromPaths = append(fromPaths, toPath)
retFromPaths = FilterSelfChildDocs(fromPaths)
retFromPaths = gulu.Str.ExcludeElem(retFromPaths, []string{toPath})
return
}
func FilterSelfChildDocs(paths []string) (ret []string) {
sort.Slice(paths, func(i, j int) bool { return len(paths[i]) < len(paths[j]) })
sort.Slice(paths, func(i, j int) bool { return strings.Count(paths[i], "/") < strings.Count(paths[j], "/") })
dirs := map[string]string{}
for _, fromPath := range paths {