Replace saved copies that fail to play, reject truncated saves, and re-check the device cache when the app returns to the foreground
This commit is contained in:
@@ -75,6 +75,12 @@ self.onmessage = async (e) => {
|
||||
} finally {
|
||||
access.close();
|
||||
}
|
||||
// A connection that ends early can close the body cleanly; never commit
|
||||
// a truncated file, it would be badged "cached" yet fail to play.
|
||||
const expected = Number(res.headers.get('content-length'));
|
||||
if (expected > 0 && offset !== expected) {
|
||||
throw new Error(`download cut short (${offset} of ${expected} bytes)`);
|
||||
}
|
||||
|
||||
// Finalize: .part → permanent name. Prefer the native rename, but treat
|
||||
// ANY move() failure as "unavailable" and fall back to a chunked copy —
|
||||
|
||||
Reference in New Issue
Block a user