Some checks failed
build / build (push) Has been cancelled
clearAll() previously only wiped finalized files + the IN_FLIGHT set; any download that was already running on the single-thread executor kept writing past the clear, then atomically moved its .part to final and re-published into READY — resurrecting one cache entry post-clear. Fix: add an AtomicLong CACHE_EPOCH. preload() captures the epoch at submit time; clearAll() bumps the epoch BEFORE wiping disk; download(url, epoch) checks at three points (pre-start, in read loop, pre-publish) and bails if the epoch moved, deleting its own .part only AFTER closing the output stream (Windows can't delete an open file). Phase ordering in clearAll() also matters: bump epoch first → drop indexes → delete files. That way the in-flight download sees the cancellation flag before the index wipe / file delete races can interact with it.
457 B
457 B