feat: expose archive host paths in project payload (REQ-172)

This commit is contained in:
Andrew-AAAA committed 2026-09-29 08:47:19 +07:00
1 parent e2f4a51838
commit 712cdeabf1
4 files changed
+28 -1

No files matched your search

+21
View File
@@ -22,6 +22,27 @@ DB_PATH = os.path.join(DATA_DIR, "app.db")
# they store an absolute one — but this is the default the UI starts browsing from.
VIDEO_ROOT = os.path.abspath(os.environ.get("VIDEO_ARCHIVE", os.path.join(DATA_DIR, "archive")))
def archive_host_paths() -> dict:
"""Where the archive sits on the host — for the copy-path buttons (REQ-172).
ponytail: relative VIDEO_ARCHIVE_HOST (./data/archive) cannot be resolved
inside the container; set it absolute in .env or the buttons stay hidden."""
import re
host = os.environ.get("VIDEO_ARCHIVE_HOST", "")
if os.path.isabs(host):
linux = host.rstrip("/")
elif VIDEO_ROOT != "/videos": # bare-metal: VIDEO_ROOT is already the host path
linux = VIDEO_ROOT
else:
return {"linux": None, "windows": None}
if re.match(r"^[A-Za-z]:[\\/]", linux):
return {"linux": None, "windows": linux.replace("/", "\\")}
distro = os.environ.get("WSL_DISTRO_NAME", "")
windows = f"\\\\wsl.localhost\\{distro}\\" + linux.lstrip("/").replace("/", "\\") if distro else None
return {"linux": linux, "windows": windows}
# Vite dev server needs cross-origin access; in Docker nginx proxies /api and
# this is irrelevant.
CORS_ORIGINS = [
+2
View File
@@ -178,6 +178,8 @@ def _row_to_dict(cur, row) -> dict:
"secondary_model_classes": sec_classes,
"base_model_fallback": PRETRAINED[row["label_type"]],
"video_root": row["video_root"],
"video_root_linux": config.archive_host_paths()["linux"],
"video_root_windows": config.archive_host_paths()["windows"],
"val_every": row["val_every"],
"created_at": row["created_at"],
"classes": classes,