mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
Simpler method for getting key count
This commit is contained in:
@@ -560,8 +560,7 @@ async function thumbCacheCleanup() {
|
||||
|
||||
const t0 = performance.now();
|
||||
|
||||
const idbSize = await idbGetAllKeys()
|
||||
.then(keys => keys.length)
|
||||
const idbSize = await idbCount()
|
||||
.catch(() => 0);
|
||||
|
||||
if (idbSize < thumbHashes.size + 100) {
|
||||
|
||||
+13
-1
@@ -79,7 +79,7 @@ async function idbGetAllKeys() {
|
||||
if (!db) return null;
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = db
|
||||
.transaction("thumbs")
|
||||
.transaction("thumbs", "readonly")
|
||||
.objectStore("thumbs")
|
||||
.getAllKeys();
|
||||
request.onsuccess = () => resolve(request.result);
|
||||
@@ -87,6 +87,18 @@ async function idbGetAllKeys() {
|
||||
});
|
||||
}
|
||||
|
||||
async function idbCount() {
|
||||
if (!db) return null;
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = db
|
||||
.transaction("thumbs", "readonly")
|
||||
.objectStore("thumbs")
|
||||
.count();
|
||||
request.onsuccess = () => resolve(request.result);
|
||||
request.onerror = (evt) => reject(evt);
|
||||
});
|
||||
}
|
||||
|
||||
async function idbClean(keepSet) {
|
||||
if (!db) return null;
|
||||
if (!keepSet instanceof Set) {
|
||||
|
||||
Reference in New Issue
Block a user