Update names/info and ensure folder is string

This commit is contained in:
awsr
2025-11-27 18:34:11 -08:00
parent d7ddc953b9
commit 8197cbefaa
3 changed files with 6 additions and 7 deletions
+1 -1
View File
@@ -635,7 +635,7 @@ async function thumbCacheCleanup(folder, imgCount) {
idbIsCleaning = true;
const [updateCleaningMsg, removeOverlayFunc] = showCleaningMsg();
idbClean(staticGalleryHashes, folder, updateCleaningMsg)
idbFolderCleanup(staticGalleryHashes, folder, updateCleaningMsg)
.then((delcount) => {
const t1 = performance.now();
log(`Thumbnail DB cleanup: folder=${folder} kept=${staticGalleryHashes.size} deleted=${delcount} time=${Math.floor(t1 - t0)}ms`);
+4 -5
View File
@@ -123,16 +123,15 @@ async function idbCount(folder = null) {
* @param {string} folder - Folder name/path
* @param {updateMsgCallback} msgCallback - Callback for updating progress display
*/
async function idbClean(keepSet, folder, msgCallback) {
async function idbFolderCleanup(keepSet, folder, msgCallback) {
if (!db) return null;
if (!(keepSet instanceof Set)) {
throw new TypeError('IndexedDB cleaning function must be given a Set() of hashes to keep');
throw new TypeError('IndexedDB cleaning function must be given a Set() of the current gallery hashes');
}
if (!folder) {
if (!folder || typeof folder !== 'string') {
throw new Error('IndexedDB cleaning function must be told the current active folder');
}
const folderCached = new Set(await idbGetAllKeys('folder', folder));
const removals = folderCached.difference(keepSet);
const removals = (new Set(await idbGetAllKeys('folder', folder))).difference(keepSet);
const totalRemovals = removals.size;
let counter = 0;
return new Promise((resolve, reject) => {