0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 20:42:43 +00:00

Simplify garbage collection

This commit is contained in:
G.Ambatte
2024-10-09 17:27:33 +13:00
parent aa68762294
commit 0b44e68a36

View File

@@ -117,19 +117,13 @@ export async function updateHistory(brew) {
export async function versionHistoryGarbageCollection(){
await IDB.entries(await createHBStore())
.then((entries)=>{
entries.forEach(async (entry)=>{
const key = entry[0];
const value = entry[1];
const entries = await IDB.entries(await createHBStore());
// if(key.startsWith(`${HISTORY_PREFIX}`)) { // This check was to make sure we were only selecting the history keys, should be unnecessary
const collectAt = new Date(value.savedAt);
collectAt.setMinutes(collectAt.getMinutes() + GARBAGE_COLLECT_DELAY);
if(new Date() > collectAt){
IDB.del(key, await createHBStore());
};
// }
});
});
for (const [key, value] of entries){
const expireAt = new Date(value.savedAt);
expireAt.setMinutes(expireAt.getMinutes() + GARBAGE_COLLECT_DELAY);
if(new Date() > expireAt){
IDB.del(key, await createHBStore());
};
};
};