chore: Add deprecation warnings and update documentation (Task 9)

Task 9: Clean up legacy code
- Added deprecation warnings to Serie.save_to_file() and load_from_file()
- Updated infrastructure.md with Data Storage section documenting:
  - SQLite database as primary storage
  - Legacy file storage as deprecated
  - Data migration process
- Added deprecation warning tests for Serie class
- Updated existing tests to handle new warnings
- All 1012 tests pass (872 unit + 55 API + 85 integration)
This commit is contained in:
2025-12-01 19:55:15 +01:00
parent 73283dea64
commit 396b243d59
7 changed files with 678 additions and 23 deletions

View File

@@ -164,6 +164,53 @@ All series-related WebSocket events include `key` as the primary identifier in t
- `AnimeSeriesService.get_by_id(id)` - Internal lookup by database ID
- No `get_by_folder()` method exists - folder is never used for lookups
## Data Storage
### Storage Architecture
The application uses **SQLite database** as the primary storage for anime series metadata. This replaces the legacy file-based storage system.
| Storage Method | Status | Location | Purpose |
| -------------- | --------------------- | ------------------------- | ------------------------------ |
| SQLite DB | **Primary (Current)** | `data/aniworld.db` | All series metadata and state |
| Data Files | **Deprecated** | `{anime_dir}/*/data` | Legacy per-series JSON files |
### Database Storage (Recommended)
All new series are stored in the SQLite database via `AnimeSeriesService`:
```python
# Add series to database
await AnimeSeriesService.create(db_session, series_data)
# Query series by key
series = await AnimeSeriesService.get_by_key(db_session, "attack-on-titan")
# Update series
await AnimeSeriesService.update(db_session, series_id, update_data)
```
### Legacy File Storage (Deprecated)
The legacy file-based storage is **deprecated** and will be removed in v3.0.0:
- `Serie.save_to_file()` - Deprecated, use `AnimeSeriesService.create()`
- `Serie.load_from_file()` - Deprecated, use `AnimeSeriesService.get_by_key()`
- `SerieList.add()` - Deprecated, use `SerieList.add_to_db()`
Deprecation warnings are raised when using these methods.
### Data Migration
On application startup, the system automatically migrates legacy data files to the database:
1. **Scan**: `DataMigrationService.scan_for_data_files()` finds legacy `data` files
2. **Migrate**: `DataMigrationService.migrate_data_file()` imports each file to DB
3. **Skip**: Existing series (by key) are skipped; changed episode data is updated
4. **Log**: Migration results are logged at startup
Migration is idempotent and safe to run multiple times.
## Core Services
### SeriesApp (`src/core/SeriesApp.py`)