From 68048bfb2b50f2c7f36ee3a15cf6bc3d26bef78c Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Mon, 12 Feb 2024 21:45:10 -0500 Subject: [PATCH 1/2] library_idbfs.js: Handle transaction.onabort in reconcile() If the transaction aborts (which can happen due to, for example, a QuotaExceededError), `onabort` must be handled to ensure that the `callback` actually gets called. --- src/library_idbfs.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/library_idbfs.js b/src/library_idbfs.js index 7a670928aab6d..be6f0a0185b18 100644 --- a/src/library_idbfs.js +++ b/src/library_idbfs.js @@ -280,6 +280,12 @@ addToLibrary({ } }; + // transaction may abort if (for example) there is a QuotaExceededError + transaction.onabort = (e) => { + done(e.target.error); // DOMException + e.preventDefault(); + }; + // sort paths in ascending order so directory entries are created // before the files inside them create.sort().forEach((path) => { From 4d24e0db4315bf30f708cd2a8cb07338f27e4d39 Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Tue, 13 Feb 2024 16:20:45 -0500 Subject: [PATCH 2/2] library_idbfs.js: Also use e.target.error for transaction.onerror --- src/library_idbfs.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/library_idbfs.js b/src/library_idbfs.js index be6f0a0185b18..3f482866b53d7 100644 --- a/src/library_idbfs.js +++ b/src/library_idbfs.js @@ -269,8 +269,9 @@ addToLibrary({ } }; - transaction.onerror = (e) => { - done(this.error); + // transaction may abort if (for example) there is a QuotaExceededError + transaction.onerror = transaction.onabort = (e) => { + done(e.target.error); e.preventDefault(); }; @@ -280,12 +281,6 @@ addToLibrary({ } }; - // transaction may abort if (for example) there is a QuotaExceededError - transaction.onabort = (e) => { - done(e.target.error); // DOMException - e.preventDefault(); - }; - // sort paths in ascending order so directory entries are created // before the files inside them create.sort().forEach((path) => {