test_models: cache API logs by path (#4066)

This commit is contained in:
Daniel Koepping
2026-11-28 11:50:18 -06:00
committed by firestar5683
parent 2c8ac79b1b
commit 406484fff1
@@ -78,7 +78,9 @@ def get_cached_segment(route: str, segment: int) -> Path:
def get_cached_url(url: str) -> Path:
cache_path = DOWNLOAD_CACHE_ROOT / f"{hashlib.sha256(url.encode()).hexdigest()}{Path(url).suffix}"
# the API signs its URLs again on each request
base = url.split('?', 1)[0]
cache_path = DOWNLOAD_CACHE_ROOT / f"{hashlib.sha256(base.encode()).hexdigest()}{Path(base).suffix}"
if not cache_path.exists():
cache_path.parent.mkdir(parents=True, exist_ok=True)
tmp_path = cache_path.with_suffix(f".{os.getpid()}.tmp")