From cf89d4c98e1848a5a99e28503c1ad1feb4e2cd3d Mon Sep 17 00:00:00 2001 From: Skyler Grey Date: Wed, 8 Mar 2023 00:19:33 +0000 Subject: [PATCH] Upsert the scanCache rather than inserting --- src/utils/database.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/database.ts b/src/utils/database.ts index a107d06..c5697f3 100644 --- a/src/utils/database.ts +++ b/src/utils/database.ts @@ -606,9 +606,10 @@ export class ScanCache { } async write(hash: string, type: "nsfw" | "malware" | "bad_link", data: boolean, tags?: string[]) { - await this.scanCache.insertOne( + await this.scanCache.updateOne( + { hash: hash }, { hash: hash, [type]: data, tags: tags ?? [], addedAt: new Date() }, - collectionOptions + Object.assign({ upsert: true }, collectionOptions) ); }