NoDataFile #2

Merged
lukas.pupkalipinski merged 6 commits from NoDataFile into main 2026-01-11 19:15:45 +01:00
3 changed files with 31 additions and 40 deletions
Showing only changes of commit 281b982abe - Show all commits

View File

@ -108,47 +108,40 @@ For each task completed:
## TODO List: ## TODO List:
### Task: Refactor Series Addition and Folder Creation Logic ### Task: Fix Scanner Availability for Series Addition
**Priority:** High **Priority:** High
**Status:** ✅ Complete **Status:** ✅ Complete
#### Overview #### Problem
After adding a series, the targeted scan was being skipped with the message:
```
INFO: Scanner not directly available, skipping targeted scan for romantic-killer
```
Refactored the series addition workflow to defer folder creation until download time and ensure proper series scanning on addition. This improves the separation of concerns and ensures a cleaner workflow. #### Root Cause
The code was checking for `series_app.scanner`, but the actual attribute name in SeriesApp is `serie_scanner`.
#### Completed Changes #### Changes Made
1. **Folder Creation Removed from Series Addition** 1. **Fixed [src/server/api/anime.py](../src/server/api/anime.py)**:
- Modified [src/server/api/anime.py](../src/server/api/anime.py) to remove folder creation on series add - Changed `hasattr(series_app, "scanner")` to `hasattr(series_app, "serie_scanner")`
- Series are now only added to the database and in-memory structures - Changed `series_app.scanner.scan_single_series()` to `series_app.serie_scanner.scan_single_series()`
- Folder creation is deferred to download time - Updated fallback message to be a warning instead of info
2. **Folder Creation Added to Download Start** 2. **Fixed [tests/api/test_anime_endpoints.py](../tests/api/test_anime_endpoints.py)**:
- Updated [src/core/SeriesApp.py](../src/core/SeriesApp.py) `download()` method - Changed `self.scanner = FakeScanner()` to `self.serie_scanner = FakeScanner()`
- Added folder existence check before download - Added comment explaining the attribute name matches SeriesApp
- Creates folder if it doesn't exist using the series folder name
- Includes proper error handling and logging
3. **Database Persistence Maintained**
- Series are still properly saved to the database on addition
- No regression in database entry creation
4. **Targeted Scanning Works**
- Scan logic continues to work correctly
- Only the added series is scanned (not full library rescan)
- Works correctly even when folder doesn't exist yet
#### Test Results #### Test Results
- ✅ All 9 add_series endpoint tests passing
- ✅ Scanner is now correctly detected and called
- ✅ Targeted scanning works when adding series
- All add_series endpoint tests passing (9/9) #### Expected Behavior After Fix
- All SeriesApp download tests passing (4/4) When adding a series, you should now see:
- Total: 1132 tests passing (up from 1123 before changes) ```
- Remaining failures are unrelated to these changes (scan_service, download_service issues) INFO: Targeted scan completed for romantic-killer: found X missing episodes
```
#### Note on Year Attribute
Year information is not currently available in the Serie class or search results. The folder naming currently uses just the series name without the year suffix. This can be enhanced in a future task when year metadata is added to the system.
--- ---

View File

@ -761,8 +761,8 @@ async def add_series(
# Step E: Trigger targeted scan for missing episodes # Step E: Trigger targeted scan for missing episodes
try: try:
if series_app and hasattr(series_app, "scanner"): if series_app and hasattr(series_app, "serie_scanner"):
missing_episodes = series_app.scanner.scan_single_series( missing_episodes = series_app.serie_scanner.scan_single_series(
key=key, key=key,
folder=folder folder=folder
) )
@ -776,12 +776,10 @@ async def add_series(
if hasattr(series_app, "list") and hasattr(series_app.list, "keyDict"): if hasattr(series_app, "list") and hasattr(series_app.list, "keyDict"):
if key in series_app.list.keyDict: if key in series_app.list.keyDict:
series_app.list.keyDict[key].episodeDict = missing_episodes series_app.list.keyDict[key].episodeDict = missing_episodes
elif anime_service: else:
# Fallback to anime_service if scanner not directly available # Scanner not available - this shouldn't happen in normal operation
# Note: This is a lightweight scan, not a full rescan logger.warning(
logger.info( "Scanner not available for targeted scan of %s",
"Scanner not directly available, "
"skipping targeted scan for %s",
key key
) )
except Exception as e: except Exception as e:

View File

@ -42,7 +42,7 @@ class FakeSeriesApp:
def __init__(self): def __init__(self):
"""Initialize fake series app.""" """Initialize fake series app."""
self.list = self # Changed from self.List to self.list self.list = self # Changed from self.List to self.list
self.scanner = FakeScanner() # Add fake scanner self.serie_scanner = FakeScanner() # Add fake scanner (matches SeriesApp attribute name)
self.directory = "/tmp/fake_anime" self.directory = "/tmp/fake_anime"
self.keyDict = {} # Add keyDict for direct access self.keyDict = {} # Add keyDict for direct access
self._items = [ self._items = [