From 2ff9e81cc418090aad6e4d623b6da3a985756487 Mon Sep 17 00:00:00 2001 From: Julian Tabel Date: Sun, 8 Feb 2026 22:32:00 +0100 Subject: [PATCH] Fix image export in container and skip already-local URLs Mount frontend/public into the api container so the export can write badge/sprite images. Skip re-downloading URLs that are already local paths from a previous export. Co-Authored-By: Claude Opus 4.6 --- backend/src/app/seeds/run.py | 8 ++++++++ docker-compose.yml | 1 + 2 files changed, 9 insertions(+) diff --git a/backend/src/app/seeds/run.py b/backend/src/app/seeds/run.py index b2e27f1..95d031a 100644 --- a/backend/src/app/seeds/run.py +++ b/backend/src/app/seeds/run.py @@ -425,6 +425,14 @@ def _download_image( Returns the local path (relative to frontend/public). """ + # Already a local path — check the file exists, otherwise re-derive the path + if url.startswith("/"): + local = FRONTEND_PUBLIC / url.lstrip("/") + if local.exists(): + return url + # File missing — can't re-download without the original URL, keep as-is + return url + url_ext = url.rsplit(".", 1)[-1].split("?")[0].lower() if url_ext in ("png", "jpg", "jpeg", "gif", "webp", "svg"): ext = f".{url_ext}" diff --git a/docker-compose.yml b/docker-compose.yml index 8e0cb9c..c892a44 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,7 @@ services: volumes: - ./backend/src:/app/src:cached - ./backend/alembic.ini:/app/alembic.ini:cached + - ./frontend/public:/frontend/public environment: - DEBUG=true - DATABASE_URL=postgresql://postgres:postgres@db:5432/nuzlocke