chore: snapshot workflow migration progress

This commit is contained in:
2026-04-12 11:49:04 +02:00
parent 0cd02513d5
commit 3e810c74a3
163 changed files with 31774 additions and 2753 deletions
+5 -19
View File
@@ -30,6 +30,7 @@ from app.schemas.order_line import OrderLineCreate, OrderLineOut
from app.schemas.product import ProductOut
from app.schemas.output_type import OutputTypeOut
from app.services.order_service import generate_order_number
from app.core.render_paths import resolve_result_path, result_path_to_public_url
from app.utils.auth import get_current_user, require_admin_or_pm, require_pm_or_above
router = APIRouter(prefix="/orders", tags=["orders"])
@@ -41,13 +42,7 @@ def _is_privileged(user: User) -> bool:
def _result_path_to_url(result_path: str) -> str | None:
"""Convert an internal result_path to a servable static URL."""
if "/renders/" in result_path:
idx = result_path.index("/renders/")
return result_path[idx:]
if "/thumbnails/" in result_path:
idx = result_path.index("/thumbnails/")
return result_path[idx:]
return None
return result_path_to_public_url(result_path, require_exists=True)
def _build_line_out(line: OrderLine) -> OrderLineOut:
@@ -1544,15 +1539,6 @@ async def download_renders(
if not lines:
raise HTTPException(404, detail="No completed renders found for this order")
from app.config import settings as app_settings
def _resolve_path(p: str) -> str:
"""Translate container-relative paths to backend filesystem paths."""
# Flamenco worker mounts the uploads volume at /shared, backend at /app/uploads
if p.startswith("/shared/"):
return app_settings.upload_dir + p[len("/shared"):]
return p
buf = io.BytesIO()
# Track names used to avoid duplicates
name_counts: dict[str, int] = {}
@@ -1561,8 +1547,8 @@ async def download_renders(
for line in lines:
if not line.result_path:
continue
fs_path = _resolve_path(line.result_path)
if not os.path.isfile(fs_path):
resolved_path = resolve_result_path(line.result_path)
if resolved_path is None or not resolved_path.is_file():
continue
# Build a meaningful filename
product_name = (line.product.name or line.product.pim_id or "product") if line.product else "product"
@@ -1587,7 +1573,7 @@ async def download_renders(
name_counts[base_name] = 0
archive_name = base_name
zf.write(fs_path, archive_name)
zf.write(resolved_path, archive_name)
if not zf.infolist():
raise HTTPException(404, detail="No render files found on disk")