Skip to content

Commit 2c694da

Browse files
committed
fix(config): negative cache age must miss, not hit
Registry.from_url checked `if age < cache_max_age_seconds` to decide cache hit/miss. On Windows, the freshly-renamed cache file sometimes reports an `st_mtime` slightly in the future of `time.time()` due to filesystem-time vs wall-clock precision skew. That made `age` negative, which (correctly per <) satisfied any positive `cache_max_age_seconds`, but also incorrectly satisfied `cache_max_age_seconds=0` — turning the documented "always refetch" semantic into "use stale cache". Tightened to `0 <= age < cache_max_age_seconds`. Negative ages now trigger a refetch on every platform; positive ages behave unchanged. Surfaced by tests/test_remote_registry.py::test_from_url_refresh_ bypasses_cache on windows-latest after the matrix cleanup in 56c3bfd exposed Windows runners (previously all queued behind ARM).
1 parent aae2045 commit 2c694da

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/get_installer/config.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,12 @@ def from_url(
274274
cache_path = cd / f"registry-{key}.json"
275275
if cache_path.is_file():
276276
age = _time.time() - cache_path.stat().st_mtime
277-
if age < cache_max_age_seconds:
277+
# Reject negative ages: on Windows (and some FUSE mounts)
278+
# st_mtime can land slightly in the future after a rename
279+
# because of filesystem-time vs wall-clock precision skew.
280+
# `cache_max_age_seconds=0` must always bypass the cache,
281+
# so guard the comparison from below.
282+
if 0 <= age < cache_max_age_seconds:
278283
try:
279284
data = json.loads(cache_path.read_text(encoding="utf-8"))
280285
return cls.from_dict(data, source_path=cache_path)

0 commit comments

Comments
 (0)