- Remove settings.reload() call which doesn't exist in Pydantic BaseSettings
- Manually sync anime_directory and NFO settings from config.json to settings object
- Mirrors the sync logic used in fastapi_app.py lifespan
- Fixes AttributeError: 'Settings' object has no attribute 'reload'
- Create initialization_service.py with shared initialization functions
- Extract setup logic from lifespan and setup endpoint into reusable functions
- Setup endpoint now calls perform_initial_setup() directly
- Lifespan startup calls the same shared functions
- Eliminates code duplication between setup and lifespan
- Ensures consistent initialization behavior regardless of entry point
- Add mark_initial_scan_completed() call to /api/auth/setup endpoint
- Ensures initial_scan_completed flag is set to True after first sync
- Prevents duplicate folder scans on subsequent application startups
- Include error handling to prevent setup failure if marking fails
- Modified SeriesManagerService to create SerieList with skip_load=True
- Changed scan_and_process_nfo() to load series from database instead of filesystem
- Fixed database transaction issue by creating separate session per task
- Verified scans only run once during initial setup, not on normal startup
- Test media scan runs on first startup
- Test media scan skipped on subsequent startup
- Test error handling for flag check/mark
- Test _check_incomplete_series_on_startup behavior
- Test detection of incomplete series
- Test all edge cases (8 tests total)
Task 3 (NFO data):
- Add parse_nfo_ids() method to NFOService
- Extract TMDB/TVDB IDs from NFO files during scan
- Update database with extracted IDs
- Add comprehensive unit and integration tests
Task 4 (Media scan):
- Track initial media scan with SystemSettings flag
- Run background loading only on first startup
- Skip media scan on subsequent runs
- Add NFO scanning to startup process (fastapi_app.py)
- Check initial_nfo_scan_completed flag before running NFO scan
- Run NFO scan only on first startup if TMDB API key is configured
- Mark NFO scan as completed after first successful run
- Skip NFO scan on subsequent startups
This ensures NFO metadata processing only occurs during initial setup,
not on every application restart, improving startup performance.
- Add SystemSettings model to track setup completion status
- Create SystemSettingsService for managing setup flags
- Modify fastapi_app startup to check and set initial_scan_completed flag
- Anime folder scanning now only runs on first startup
- Update DATABASE.md with new system_settings table documentation
- Add unit test for SystemSettingsService functionality
This ensures expensive one-time operations like scanning the entire anime
directory only occur during initial setup, not on every application restart.
- Test that SeriesApp.list starts empty with skip_load=True
- Test that load_series_from_list populates the keyDict correctly
- Test that _load_series_from_db loads series from database into memory
- Test that /api/anime endpoint returns series after loading
- Test empty database edge case
- Test episode dict conversion from DB format
- All 7 tests passing
- Root cause: Server needed restart to complete initialization
- Startup process syncs data files to DB and loads into memory
- Verified: GET /api/anime returns 192 anime with full metadata
- Added _find_series_directory() to locate series without full rescan
- Added _scan_series_episodes() to scan only target series directory
- Modified _load_episodes() to use targeted scanning instead of anime_service.rescan()
- Added 15 comprehensive unit tests for optimization
- Performance improvement: <1s vs 30-60s for large libraries
- All tests passing (15 new tests + 14 existing background loader tests)
- Changed 'async for' to 'async with' for get_db_session()
- get_db_session() is @asynccontextmanager, requires async with not async for
- Created 5 comprehensive unit tests verifying the fix
- All tests pass, background loading now works correctly
- Created test_dependency_exception_handling.py with 5 comprehensive tests
- Tests verify proper handling of HTTPException in async generator dependencies
- All tests pass, confirming fix for 'generator didn't stop after athrow()' error
- Updated instructions with complete task documentation
- Add proper exception handling in get_database_session and get_optional_database_session
- Prevents 'generator didn't stop after athrow()' error when HTTPException is raised
- Add mock for BackgroundLoaderService in anime endpoint tests
- Update test expectations to match 202 Accepted response for async add_series endpoint
- Create detailed testing guide with 10 test scenarios
- Include step-by-step instructions and expected results
- Add troubleshooting section and verification checklist
- Provide performance metrics template
- Update instructions.md with testing information
- Mark async series loading task as completed
- Document test coverage (10/10 unit, 4/9 integration)
- List all created and modified files
- Note remaining manual testing needed
- Add SERIES_LOADING_UPDATE WebSocket event
- Update series cards to display loading indicators
- Add real-time status updates via WebSocket
- Include progress tracking (episodes, NFO, logo, images)
- Add CSS styling for loading states
- Implement updateSeriesLoadingStatus function
- Add loading status fields to AnimeSeries model
- Create BackgroundLoaderService for async task processing
- Update POST /api/anime/add to return 202 Accepted immediately
- Add GET /api/anime/{key}/loading-status endpoint
- Integrate background loader with startup/shutdown lifecycle
- Create database migration script for loading status fields
- Add unit tests for BackgroundLoaderService (10 tests, all passing)
- Update AnimeSeriesService.create() to accept loading status fields
Architecture follows clean separation with no code duplication:
- BackgroundLoader orchestrates, doesn't reimplement
- Reuses existing AnimeService, NFOService, WebSocket patterns
- Database-backed status survives restarts
- Moved sync_series_from_data_files() before DownloadService init
- Ensures series are in DB before main SeriesApp creation
- Eliminates redundant SeriesApp instantiation during startup
- Updated README to clarify initialization sequence
- SeriesApp now passes skip_load=True to SerieList
- Prevents redundant data file loading on every startup
- Series loaded once during setup via sync_series_from_data_files()
- Removed obsolete _init_list_sync() and _init_list() methods
- Updated documentation in ARCHITECTURE.md and README.md
- Add Serie.ensure_folder_with_year() method to ensure folder names include year
- Update all NFO API endpoints to call ensure_folder_with_year() before operations
- Folder format is now 'Name (Year)' when year is available
- Add comprehensive tests for ensure_folder_with_year() method
- All 5 tests passing
- Add response.json() calls in nfo-manager.js for all API calls
- Add response.json() calls in nfo-config.js for all API calls
- Fix createNFO, refreshNFO, viewNFO, getSeriesWithoutNFO functions
- Fix load and testTMDBConnection functions
- All API responses must be parsed before accessing properties
- Load TMDB API key and NFO settings from config.json
- Sync NFO config to settings during app startup
- NFO endpoints now work correctly (no more 503)
- Fixed async context manager issue in anime.py (use get_sync_session)
- Fixed async methods in anime_service.py to use async with
- Fixed folder_name attribute error (should be folder)
- All three methods now properly handle database sessions
- Fix test_data_file_db_sync.py: Remove unused mock logger parameters
- Fix test_nfo_workflow.py: Add missing async mocks for TMDB methods
* Add get_tv_show_content_ratings mock for FSK rating support
* Add get_image_url mock to return proper URL strings
* Fix test_nfo_update_workflow to include TMDB ID in existing NFO
- Fix DownloadService method calls in test fixtures
* Change stop() to stop_downloads() (correct method name)
* Change start() to start_queue_processing()
* Add exception handling for ProgressServiceError in teardown
- All 1380 tests now passing with 0 failures and 0 errors
- Add 23 new unit tests for media downloads in test_nfo_service.py
- Create test_nfo_integration.py with 10 integration tests
- Test all media download scenarios (poster/logo/fanart)
- Test various image sizes and configurations
- Test concurrent NFO operations
- Test error handling and edge cases
- All 44 NFO service tests passing
- All 10 integration tests passing