feat: resolve relative VIDEO_ARCHIVE_HOST via compose cwd (portable copy-path)

This commit is contained in:
Andrew-AAAA committed 2026-09-30 12:03:20 +07:00
1 parent 7a7393d7a5
commit a3f2e01c20
3 files changed
+31 -10

No files matched your search

+11 -7
View File
@@ -26,16 +26,20 @@ VIDEO_ROOT = os.path.abspath(os.environ.get("VIDEO_ARCHIVE", os.path.join(DATA_D
def archive_host_paths() -> dict:
"""Where the archive sits on the host — for the copy-path buttons (REQ-179).
ponytail: relative VIDEO_ARCHIVE_HOST (./data/archive) cannot be resolved
inside the container; set it absolute in .env or the buttons stay hidden."""
VIDEO_ARCHIVE_HOST may stay relative (portable across machines): compose
injects the host cwd as ARCHIVE_HOST_PWD (compose always has PWD — a
Windows-side run yields a drive-letter path, handled below), bare-metal
resolves against the process cwd (start.sh cds to the repo root)."""
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:
if host and not os.path.isabs(host):
base = os.environ.get("ARCHIVE_HOST_PWD") or os.getcwd()
host = os.path.abspath(os.path.join(base, host))
if not host and VIDEO_ROOT != "/videos":
host = VIDEO_ROOT # bare-metal with no VIDEO_ARCHIVE_HOST at all
if not host:
return {"linux": None, "windows": None}
linux = host.rstrip("/")
if re.match(r"^[A-Za-z]:[\\/]", linux):
return {"linux": None, "windows": linux.replace("/", "\\")}
distro = os.environ.get("WSL_DISTRO_NAME", "")