mirror of
https://github.com/platformio/platformio-core.git
synced 2026-07-04 23:41:03 +02:00
8898b94af4
* Avoid infinite loop when cached mirror redirect keeps failing The registry mirror iterator caches the HEAD redirect for one hour, but the cache hit path never advanced _visited_mirrors, and the cached payload did not include X-PIO-Mirror. When a prior run cached a redirect to a mirror that now fails (for example an SSL error on the download), subsequent iterations kept hitting the same cache key and returning the same failing mirror forever, so tool installs looped until interrupted. Store X-PIO-Mirror in the cached payload, and on cache hit only reuse the entry if it names a mirror not already tried; otherwise fall through to a fresh HEAD with bypass set. Stale cache entries written before this change lack X-PIO-Mirror and fall through naturally, so the fix self heals without a manual cache clear. * Add unit tests for registry mirror iterator cache handling Cover the cache hit path advancing _visited_mirrors, stale cache entries without X-PIO-Mirror falling through to a fresh HEAD, and new HEAD responses persisting X-PIO-Mirror so later runs can tell whether the cached redirect still names an untried mirror. Each test fails against the previous iterator implementation. * Add type annotations to mirror iterator tests * Use typing.X annotations for 3.6 compatibility * Satisfy pylint and black on mirror iterator tests