"""Cache-path helpers for workshop content. The cache lives at `$LEFT4ME_ROOT/workshop_cache/{steam_id}.vpk`. Steam IDs are validated digit-only here so callers don't need to guard separately. """ from __future__ import annotations import re from pathlib import Path from l4d2host.paths import get_left4me_root _NUMERIC_ID_RE = re.compile(r"^\d+$") def workshop_cache_root() -> Path: return get_left4me_root() / "workshop_cache" def cache_path(steam_id: str) -> Path: if not isinstance(steam_id, str) or not _NUMERIC_ID_RE.fullmatch(steam_id): raise ValueError(f"steam_id must be digits only: {steam_id!r}") return workshop_cache_root() / f"{steam_id}.vpk"