Fix download service init when anime dir not configured

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

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
download_service = get_download_service()
await download_service.initialize()
logger.info("Download service initialized and queue restored")
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