|
|
|
|
@@ -340,11 +340,10 @@ public final class VideoCache {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Final cancellation check before publishing. If clearAll ran during the read
|
|
|
|
|
// loop's last iteration (after the loop check, before this point), we still
|
|
|
|
|
// refuse to publish — otherwise we'd resurrect a cache entry post-clear.
|
|
|
|
|
// Pre-move cancellation check. If clearAll ran during the read loop, abort
|
|
|
|
|
// before promoting .part to final — saves a wasted move + delete.
|
|
|
|
|
if (CACHE_EPOCH.get() != startEpoch) {
|
|
|
|
|
VideoPlayerMod.LOG.info("[{}] preload: cancelled at publish (clearAll ran) — {}",
|
|
|
|
|
VideoPlayerMod.LOG.info("[{}] preload: cancelled before move (clearAll ran) — {}",
|
|
|
|
|
VideoPlayerMod.MOD_ID, url);
|
|
|
|
|
try { Files.deleteIfExists(partPath); } catch (Throwable ignored) {}
|
|
|
|
|
return;
|
|
|
|
|
@@ -352,6 +351,21 @@ public final class VideoCache {
|
|
|
|
|
|
|
|
|
|
Files.move(partPath, finalPath, StandardCopyOption.REPLACE_EXISTING,
|
|
|
|
|
StandardCopyOption.ATOMIC_MOVE);
|
|
|
|
|
|
|
|
|
|
// Post-move cancellation check. clearAll() may have run between the pre-move
|
|
|
|
|
// check above and the move itself — in that case clearAll's directory scan
|
|
|
|
|
// either missed our file (it didn't exist yet) or saw the .part and skipped /
|
|
|
|
|
// failed to delete it. Either way, finalPath now exists on disk but the
|
|
|
|
|
// user-visible cache state is "cleared", so we must delete the file and skip
|
|
|
|
|
// both the READY.put and the "완료" chat. Without this check, a clear right at
|
|
|
|
|
// this window leaves a resurrected file in READY and a stale "완료" message.
|
|
|
|
|
if (CACHE_EPOCH.get() != startEpoch) {
|
|
|
|
|
VideoPlayerMod.LOG.info("[{}] preload: cancelled after move (clearAll ran) — {}",
|
|
|
|
|
VideoPlayerMod.MOD_ID, url);
|
|
|
|
|
try { Files.deleteIfExists(finalPath); } catch (Throwable ignored) {}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
READY.put(url, finalPath);
|
|
|
|
|
VideoPlayerMod.LOG.info("[{}] preload: cached {} ({} bytes) -> {}",
|
|
|
|
|
VideoPlayerMod.MOD_ID, url, total, finalPath.getFileName());
|
|
|
|
|
|