From 22240b93b5330e1c59e655043be2b4fbe05aad41 Mon Sep 17 00:00:00 2001 From: awsr <43862868+awsr@users.noreply.github.com> Date: Tue, 27 Jan 2026 13:26:14 -0800 Subject: [PATCH] Abort handling helper in SimpleFunctionQueue --- javascript/gallery.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/javascript/gallery.js b/javascript/gallery.js index adec39527..0f431e18c 100644 --- a/javascript/gallery.js +++ b/javascript/gallery.js @@ -267,6 +267,14 @@ class SimpleFunctionQueue { this.#queue = []; } + static abortHandler(identifier, result) { + if (typeof result === 'string' || (result instanceof DOMException && result.name === 'AbortError')) { + log(identifier, result?.message || result); + } else { + error(identifier, result.message); + } + } + /** * @param {{ * signal: AbortSignal, @@ -1004,11 +1012,7 @@ async function thumbCacheCleanup(folder, imgCount, controller, force = false) { log(`Thumbnail DB cleanup: folder=${folder} kept=${staticGalleryHashes.size} deleted=${delcount} time=${Math.floor(t1 - t0)}ms`); }) .catch((reason) => { - if (typeof reason === 'string' || (reason instanceof DOMException && reason.name === 'AbortError')) { - log('Thumbnail DB cleanup:', reason?.message || reason); - } else { - error('Thumbnail DB cleanup:', reason.message); - } + SimpleFunctionQueue.abortHandler('Thumbnail DB cleanup:', reason); }) .finally(async () => { await new Promise((resolve) => { setTimeout(resolve, 1000); }); // Delay removal by 1 second to ensure at least minimum visibility