[hotfix] Fix cache clearing when switching folders (#4421)

* Update submodules

* Revert "Update submodules"

This reverts commit 1679ddeeea.

* Fix cache clearing when switching folders

This is more of a temporary hotfix since it will affect switching between gallery folders quickly and it'll kick off when viewing small folders.
This commit is contained in:
awsr
2025-11-25 06:58:45 -08:00
committed by GitHub
parent e64f8d7463
commit 691339773e
2 changed files with 12 additions and 6 deletions
+6 -3
View File
@@ -99,11 +99,14 @@ async function idbCount() {
});
}
async function idbClean(keepSet) {
async function idbClean(keepSet, folder = null) {
if (!db) return null;
if (!(keepSet instanceof Set)) {
throw new TypeError('IndexedDB cleaning function must be given a Set() of hashes to keep');
}
if (folder === null) {
throw new Error('IndexedDB cleaning function must be told the current active folder');
}
return new Promise((resolve, reject) => {
let counter = 0;
const request = db
@@ -113,13 +116,13 @@ async function idbClean(keepSet) {
request.onsuccess = (evt) => {
const cursor = evt.target.result;
if (cursor) {
if (!keepSet.has(cursor.key)) {
if (folder === cursor.value.folder && !keepSet.has(cursor.key)) {
cursor.delete();
counter++;
}
cursor.continue();
} else {
resolve(counter);
resolve(counter, folder);
}
};
request.onerror = (evt) => reject(evt);