Skip to content

Commit 041b6e4

Browse files
committed
fix(IndexedDB): Delete up to the last hour of logs
Signed-off-by: Marcel Klehr <[email protected]>
1 parent 0e0a426 commit 041b6e4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/lib/IndexedDB.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,14 @@ export async function freeStorageIfNecessary() {
4141
.where('dateTime').below(oneDayAgo)
4242
.delete()
4343
}
44+
45+
({usage, quota} = await navigator.storage.estimate())
46+
if (usage / quota > 0.6 || usage > MAX_STORAGE_SIZE) {
47+
const lastHour = Date.now() - 60 * 60 * 1000
48+
49+
await db.logs
50+
.where('dateTime').below(lastHour)
51+
.delete()
52+
}
4453
}
4554
}

0 commit comments

Comments
 (0)