fix: normalize organize category roots

This commit is contained in:
ShukeBta
2026-06-25 08:54:42 +08:00
parent 89af1dad32
commit 16c3ed239a
10 changed files with 213 additions and 15 deletions
@@ -111,10 +111,17 @@ func (o *OrganizerService) reclassifyScannedMedia(ctx context.Context, media mod
return false, nil
}
baseRoot := redirectOrganizeStagingRoot(o.resolveBaseRoot(ctx, &lib, ""))
baseRoot := normalizeOrganizeDestinationRoot(o.resolveBaseRoot(ctx, &lib, ""))
targetLibrary, matched := o.organizeLibraryForLayout(ctx, baseRoot, mediaType, category)
if !matched || strings.TrimSpace(targetLibrary.ID) == "" || strings.TrimSpace(targetLibrary.Path) == "" {
return false, nil
targetRoot := categoryRoot(o.organizeRoot(baseRoot, mediaType, category), category)
if dryRun {
targetLibrary = model.Library{Path: targetRoot}
} else if created, ok := o.ensureOrganizeLibraryForRoot(ctx, targetRoot, mediaType, category); ok {
targetLibrary = created
} else {
return false, nil
}
}
if strings.EqualFold(targetLibrary.ID, lib.ID) && pathWithin(media.Path, targetLibrary.Path) {
return false, nil