mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-08 14:02:41 +00:00
Simplify garbage collection
This commit is contained in:
@@ -117,19 +117,13 @@ export async function updateHistory(brew) {
|
|||||||
|
|
||||||
export async function versionHistoryGarbageCollection(){
|
export async function versionHistoryGarbageCollection(){
|
||||||
|
|
||||||
await IDB.entries(await createHBStore())
|
const entries = await IDB.entries(await createHBStore());
|
||||||
.then((entries)=>{
|
|
||||||
entries.forEach(async (entry)=>{
|
|
||||||
const key = entry[0];
|
|
||||||
const value = entry[1];
|
|
||||||
|
|
||||||
// if(key.startsWith(`${HISTORY_PREFIX}`)) { // This check was to make sure we were only selecting the history keys, should be unnecessary
|
for (const [key, value] of entries){
|
||||||
const collectAt = new Date(value.savedAt);
|
const expireAt = new Date(value.savedAt);
|
||||||
collectAt.setMinutes(collectAt.getMinutes() + GARBAGE_COLLECT_DELAY);
|
expireAt.setMinutes(expireAt.getMinutes() + GARBAGE_COLLECT_DELAY);
|
||||||
if(new Date() > collectAt){
|
if(new Date() > expireAt){
|
||||||
IDB.del(key, await createHBStore());
|
IDB.del(key, await createHBStore());
|
||||||
};
|
};
|
||||||
// }
|
};
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user