mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 17:24:32 +02:00
[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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user