fix: handle missing anime directory gracefully on startup

This commit is contained in:
2026-02-22 12:15:31 +01:00
parent 87bf0d71cd
commit bbf0a0815a
2 changed files with 13 additions and 0 deletions

View File

@@ -286,6 +286,11 @@ async def lifespan(_application: FastAPI):
except (OSError, RuntimeError, ValueError) as e:
logger.warning("Failed to initialize services: %s", e)
# Continue startup - services can be initialized later
except Exception as e: # includes HTTPException from get_anime_service
logger.warning(
"Failed to initialize services (anime directory may not exist): %s", e
)
# Continue startup - services can be configured/initialized later
logger.info("FastAPI application started successfully")
logger.info("Server running on http://127.0.0.1:8000")

View File

@@ -125,6 +125,14 @@ def get_series_app() -> SeriesApp:
import tempfile
anime_dir = tempfile.gettempdir()
settings.anime_directory = anime_dir
else:
raise HTTPException(
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
detail=(
f"Anime directory does not exist: {anime_dir}. "
"Please configure a valid path."
),
)
_series_app = SeriesApp(anime_dir)
except Exception as e: