Fix download service init when anime dir not configured

This commit is contained in:
Lukas 2025-12-02 17:36:41 +01:00
parent 3b516c0e24
commit 7c56c8bef2
10 changed files with 57 additions and 160 deletions

View File

@ -17,7 +17,7 @@
"keep_days": 30
},
"other": {
"master_password_hash": "$pbkdf2-sha256$29000$4Ny7tzZGaG2ttVaKsRZiLA$29mSesYMcIC0u0JfpP3SM7c.fEiE82.VYh9q2vZEBRw"
"master_password_hash": "$pbkdf2-sha256$29000$R0hpDWEspRSidA4BoPTemw$NL4pP6ch.3sRxe6gjQ1tM3VPntwZMoZUFAI9sTQuHPE"
},
"version": "1.0.0"
}

View File

@ -1,23 +0,0 @@
{
"name": "Aniworld",
"data_dir": "data",
"scheduler": {
"enabled": true,
"interval_minutes": 60
},
"logging": {
"level": "INFO",
"file": null,
"max_bytes": null,
"backup_count": 3
},
"backup": {
"enabled": false,
"path": "data/backups",
"keep_days": 30
},
"other": {
"master_password_hash": "$pbkdf2-sha256$29000$EUKI8d67d86ZE.K8VypF6A$4mqRLeh3WL2AsHFXNET.1D9T.weMNIE5Ffw6cIgA4ho"
},
"version": "1.0.0"
}

View File

@ -1,23 +0,0 @@
{
"name": "Aniworld",
"data_dir": "data",
"scheduler": {
"enabled": true,
"interval_minutes": 60
},
"logging": {
"level": "INFO",
"file": null,
"max_bytes": null,
"backup_count": 3
},
"backup": {
"enabled": false,
"path": "data/backups",
"keep_days": 30
},
"other": {
"master_password_hash": "$pbkdf2-sha256$29000$VooRQui9t/beGwMAgNAaQw$idnI9fpdgl0hAd7susBuX6rpux/L/k4PJ1QMQfjwpvo"
},
"version": "1.0.0"
}

View File

@ -1,23 +0,0 @@
{
"name": "Aniworld",
"data_dir": "data",
"scheduler": {
"enabled": true,
"interval_minutes": 60
},
"logging": {
"level": "INFO",
"file": null,
"max_bytes": null,
"backup_count": 3
},
"backup": {
"enabled": false,
"path": "data/backups",
"keep_days": 30
},
"other": {
"master_password_hash": "$pbkdf2-sha256$29000$/x8jxFgLofQegzAm5DzHeA$kO44/L.4b3sEDOCuzJkunefAZ9ap5jsFZP/JDaRIUt0"
},
"version": "1.0.0"
}

View File

@ -1,23 +0,0 @@
{
"name": "Aniworld",
"data_dir": "data",
"scheduler": {
"enabled": true,
"interval_minutes": 60
},
"logging": {
"level": "INFO",
"file": null,
"max_bytes": null,
"backup_count": 3
},
"backup": {
"enabled": false,
"path": "data/backups",
"keep_days": 30
},
"other": {
"master_password_hash": "$pbkdf2-sha256$29000$htA6x1jrHYPwvre2FkJoTQ$37rrE4hOMgdowfzS9XaaH/EjPDZZFSlc0RL1blcXEVU"
},
"version": "1.0.0"
}

View File

@ -1,23 +0,0 @@
{
"name": "Aniworld",
"data_dir": "data",
"scheduler": {
"enabled": true,
"interval_minutes": 60
},
"logging": {
"level": "INFO",
"file": null,
"max_bytes": null,
"backup_count": 3
},
"backup": {
"enabled": false,
"path": "data/backups",
"keep_days": 30
},
"other": {
"master_password_hash": "$pbkdf2-sha256$29000$.t.bk1IKQah1bg0BoNS6tw$TbbOVxdX4U7xhiRPPyJM6cXl5EnVzlM/3YMZF714Aoc"
},
"version": "1.0.0"
}

View File

@ -17,7 +17,7 @@
"keep_days": 30
},
"other": {
"master_password_hash": "$pbkdf2-sha256$29000$F0JIKQWAEEJoba3VGuOckw$ae64QkQc0QkMiSiO3H3Bg8mZE5nOQ8hrN5gl9LQLjnw"
"master_password_hash": "$pbkdf2-sha256$29000$JWTsXWstZYyxNiYEQAihFA$K9QPNr2J9biZEX/7SFKU94dnynvyCICrGjKtZcEu6t8"
},
"version": "1.0.0"
}

View File

@ -167,7 +167,7 @@ All series-related WebSocket events include `key` as the primary identifier in t
### DownloadQueueItem Fields
| Field | Type | Purpose |
| -------------- | ----------- | --------------------------------------------- |
| -------------- | ----------- | ----------------------------------------- |
| `id` | String (PK) | UUID for the queue item |
| `serie_id` | String | Series key for identification |
| `serie_folder` | String | Filesystem folder path |
@ -190,7 +190,7 @@ All series-related WebSocket events include `key` as the primary identifier in t
The application uses **SQLite database** as the primary storage for all application data.
| Data Type | Storage Location | Service |
| --------------- | ------------------ | ---------------------------- |
| -------------- | ------------------ | --------------------------------------- |
| Anime Series | `data/aniworld.db` | `AnimeSeriesService` |
| Episodes | `data/aniworld.db` | `AnimeSeriesService` |
| Download Queue | `data/aniworld.db` | `DownloadService` via `QueueRepository` |
@ -219,6 +219,7 @@ await repository.update_progress(item_id, progress=45.5, downloaded=450, total=1
```
**Queue Persistence Features:**
- Queue state survives server restarts
- Items in `downloading` status are reset to `pending` on startup
- Failed items within retry limit are automatically re-queued

View File

@ -126,7 +126,7 @@ For each task completed:
The download queue has been successfully migrated from JSON file to SQLite database:
| Component | Status | Description |
| ---------------------- | --------- | ------------------------------------------------ |
| --------------------- | ------- | ------------------------------------------------- |
| QueueRepository | ✅ Done | `src/server/services/queue_repository.py` |
| DownloadService | ✅ Done | Refactored to use repository pattern |
| Application Startup | ✅ Done | Queue restored from database on startup |
@ -135,6 +135,7 @@ The download queue has been successfully migrated from JSON file to SQLite datab
| Documentation Updated | ✅ Done | `infrastructure.md` updated with new architecture |
**Key Changes:**
- `DownloadService` no longer uses `persistence_path` parameter
- Queue state is persisted to SQLite via `QueueRepository`
- In-memory cache maintained for performance

View File

@ -113,11 +113,21 @@ async def lifespan(app: FastAPI):
progress_service.subscribe("progress_updated", progress_event_handler)
# Initialize download service and restore queue from database
# Only if anime directory is configured
try:
from src.server.config.settings import settings
from src.server.utils.dependencies import get_download_service
if settings.anime_directory:
download_service = get_download_service()
await download_service.initialize()
logger.info("Download service initialized and queue restored")
else:
logger.info(
"Download service initialization skipped - "
"anime directory not configured"
)
except Exception as e:
logger.warning("Failed to initialize download service: %s", e)
# Continue startup - download service can be initialized later