From f64e7d3fd7a423829d976f7d345c432eaec92563 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 12 Oct 2024 10:57:01 +1300 Subject: [PATCH] Shift grabage collection to use delMany instead of a looped del --- client/homebrew/utils/versionHistory.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/homebrew/utils/versionHistory.js b/client/homebrew/utils/versionHistory.js index 23f9e03bc..2468a48dc 100644 --- a/client/homebrew/utils/versionHistory.js +++ b/client/homebrew/utils/versionHistory.js @@ -105,11 +105,15 @@ export async function updateHistory(brew) { export async function versionHistoryGarbageCollection(){ const entries = await IDB.entries(); + const expiredKeys = []; for (const [key, value] of entries){ const expireAt = new Date(value.savedAt); expireAt.setMinutes(expireAt.getMinutes() + GARBAGE_COLLECT_DELAY); if(new Date() > expireAt){ - await IDB.del(key); + expiredKeys.push(key); }; }; + if(expiredKeys.length > 0){ + await IDB.delMany(expiredKeys); + } }; \ No newline at end of file