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 }