mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-07 05:46:38 +08:00
fix media organize and subscription workflows
This commit is contained in:
@@ -39,6 +39,7 @@ func (o *OrganizerService) reclassifyExistingMedia(ctx context.Context, req orga
|
||||
return false, nil
|
||||
}
|
||||
candidates := reclassifyExistingCandidates(req.Existing, target, req.DestRoot)
|
||||
candidates = reclassifyMoveCandidates(candidates, target)
|
||||
if len(candidates) == 0 {
|
||||
return false, nil
|
||||
}
|
||||
@@ -112,6 +113,22 @@ func reclassifyExistingCandidates(existing []string, target, destRoot string) []
|
||||
return out
|
||||
}
|
||||
|
||||
func reclassifyMoveCandidates(existing []string, target string) []string {
|
||||
targetDir := filepath.Clean(filepath.Dir(target))
|
||||
out := make([]string, 0, len(existing))
|
||||
for _, path := range existing {
|
||||
cleaned := filepath.Clean(strings.TrimSpace(path))
|
||||
if cleaned == "" || cleaned == "." {
|
||||
continue
|
||||
}
|
||||
if strings.EqualFold(filepath.Clean(filepath.Dir(cleaned)), targetDir) {
|
||||
continue
|
||||
}
|
||||
out = append(out, cleaned)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (o *OrganizerService) cleanupReclassifiedDuplicates(ctx context.Context, req organizeExistingReclassifyRequest, target string, candidates []string) (int, error) {
|
||||
cleaned := 0
|
||||
for _, oldPath := range candidates {
|
||||
|
||||
Reference in New Issue
Block a user