fix: fall back to copy when OPFS move() throws on WebKit and retry failed worker downloads on the main thread
This commit is contained in:
@@ -76,12 +76,16 @@ self.onmessage = async (e) => {
|
||||
access.close();
|
||||
}
|
||||
|
||||
// Finalize: .part → permanent name. Prefer the native rename; fall back
|
||||
// to a chunked copy (still fully inside the worker, small fixed buffers).
|
||||
// Finalize: .part → permanent name. Prefer the native rename, but treat
|
||||
// ANY move() failure as "unavailable" and fall back to a chunked copy —
|
||||
// WebKit's move() has a different signature/behavior than Chrome's and
|
||||
// throws TypeError ("Not enough arguments") rather than being absent.
|
||||
try { await dir.removeEntry(filename); } catch { /* no previous copy */ }
|
||||
let renamed = false;
|
||||
if (typeof partHandle.move === 'function') {
|
||||
await partHandle.move(filename);
|
||||
} else {
|
||||
try { await partHandle.move(filename); renamed = true; } catch { /* copy below */ }
|
||||
}
|
||||
if (!renamed) {
|
||||
const finalHandle = await dir.getFileHandle(filename, { create: true });
|
||||
const out = await finalHandle.createSyncAccessHandle();
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user