mirror of
https://github.com/vladmandic/automatic
synced 2026-09-02 11:00:46 +02:00
Update names/info and ensure folder is string
This commit is contained in:
@@ -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`);
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user