From de9406a583835dc0840da8586a6d539abdfb603f Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Wed, 31 Dec 2025 14:10:50 +0100 Subject: [PATCH] Fix patch not present in database --- patch_detector/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/patch_detector/index.ts b/patch_detector/index.ts index c3c949f..2deae83 100644 --- a/patch_detector/index.ts +++ b/patch_detector/index.ts @@ -41,9 +41,13 @@ async function compareLatestSavedPatch(client: MongoClient, newPatch : string, n const patches = database.collection("patches") const latestPatch = await patches.find().limit(1).sort({date:-1}).next() - console.log("Latest patch in database is: " + latestPatch.patch) + if(latestPatch == null) { + console.log("No previous patch recorded in database.") + } else { + console.log("Latest patch in database is: " + latestPatch.patch) + } - if(latestPatch.patch != newPatch) { + if(latestPatch == null || latestPatch.patch != newPatch) { await patches.insertOne({patch:newPatch, date:newDate}) return false }