diff --git a/javascript/gallery.js b/javascript/gallery.js index c4f483b5e..ed17499c0 100644 --- a/javascript/gallery.js +++ b/javascript/gallery.js @@ -683,10 +683,12 @@ async function thumbCacheCleanup(folder, imgCount, controller) { const t0 = performance.now(); const staticGalleryHashes = new Set(galleryHashes); // External context should be safe since this function run is guarded by AbortController/AbortSignal in the SimpleFunctionQueue const cachedHashesCount = await idbCount(folder) - .catch(() => Infinity); // Forces next check to fail if something went wrong + .catch((e) => { + error(`Thumbnail DB cleanup: Error when getting entry count for "${folder}".`, e); + return Infinity; // Forces next check to fail if something went wrong + }); if (cachedHashesCount < staticGalleryHashes.size + 500) { // Don't run when there aren't many excess entries - debug('Thumbnail DB cleanup: Maintenance is not needed yet'); return; }