diff --git a/.build_number b/.build_number index 22f557e..4ff9cbc 100644 --- a/.build_number +++ b/.build_number @@ -1 +1 @@ -271261335 +271261524 diff --git a/backend/app/routers/images.py b/backend/app/routers/images.py index 83e4480..f7c149d 100644 --- a/backend/app/routers/images.py +++ b/backend/app/routers/images.py @@ -1,6 +1,7 @@ import os import re import mimetypes +import logging from typing import Optional from fastapi import APIRouter, HTTPException, Response from fastapi.responses import FileResponse, RedirectResponse @@ -12,6 +13,7 @@ router = APIRouter(prefix="/images", tags=["images"]) _TMDB_BASE = "https://image.tmdb.org/t/p" _ALLOWED_SIZES = {"w92", "w154", "w185", "w342", "w500", "w780", "original"} +logger = logging.getLogger(__name__) def _safe_filename(path: str) -> str: @@ -91,6 +93,8 @@ async def tmdb_image(path: str, size: str = "w342"): if os.path.exists(file_path): media_type = mimetypes.guess_type(file_path)[0] or "image/jpeg" return FileResponse(file_path, media_type=media_type, headers=headers) - raise HTTPException(status_code=502, detail="Image cache failed") - except httpx.HTTPError as exc: - raise HTTPException(status_code=502, detail=f"Image fetch failed: {exc}") from exc + logger.warning("TMDB cache miss after fetch: path=%s size=%s", path, size) + except (httpx.HTTPError, OSError) as exc: + logger.warning("TMDB cache failed: path=%s size=%s error=%s", path, size, exc) + + return RedirectResponse(url=url)