fix: prevent duplicate series when same anime key exists in different folder

- Add check for existing series by key in SetupService.run to skip duplicates
- Fix Path construction in initialization_service.py cleanup function
- Update unit tests to mock get_by_key and get_series_app
This commit is contained in:
2026-06-06 19:39:32 +02:00
parent dc7d9ee5f7
commit 53fe09351f
3 changed files with 41 additions and 1 deletions

View File

@@ -378,6 +378,18 @@ class SetupService:
)
continue
# Also check if a series with this key already exists (different folder, same anime)
existing_by_key = await AnimeSeriesService.get_by_key(db, resolved_key)
if existing_by_key:
logger.debug(
"Series with key already exists, skipping",
folder=folder_name,
key=resolved_key,
existing_folder=existing_by_key.folder
)
skipped_existing += 1
continue
# Check filesystem properties
props = cls._get_series_properties(folder)