fix: try aborting writables when failed
This commit is contained in:
+2
-1
@@ -425,7 +425,7 @@ while (await new Promise(o => setTimeout(o, 1000, true))) {
|
||||
case 'CLOSING':
|
||||
if (save) try {
|
||||
$.all('#actions > button').forEach(e => e.disabled = true);
|
||||
let writable = await filehandle.createWritable({ mode: 'exclusive' });
|
||||
var writable = await filehandle.createWritable({ mode: 'exclusive' });
|
||||
let buffer = await filehandle.getFile().then(f => f.arrayBuffer());
|
||||
let data = await Rpc2.invoke('merge', { params: [new Uint8Array(buffer).toBase64()] });
|
||||
await writable.write(Uint8Array.fromBase64(data));
|
||||
@@ -433,6 +433,7 @@ while (await new Promise(o => setTimeout(o, 1000, true))) {
|
||||
await Rpc2.notify('close');
|
||||
} catch (e) {
|
||||
if (Error.isError(e) && e.name === 'NoModificationAllowedError') continue;
|
||||
await new Promise(fn => fn(writable.abort())).catch(() => null);
|
||||
alert('(ERROR) ' + new String(e ?? 'File operation failed'));
|
||||
}
|
||||
save = false;
|
||||
|
||||
Reference in New Issue
Block a user