From 96e25f716916d371f2407f82a4dd26635b361915 Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Thu, 24 Oct 2024 15:20:52 +0300 Subject: [PATCH] check if .ics file exists --- server.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server.js b/server.js index 2ca951a..bfdd02c 100644 --- a/server.js +++ b/server.js @@ -112,6 +112,15 @@ app.get('/calendar/:name', async (req, res) => { const icsFilePath = path.join(MERGED_CALENDARS_DIR, `${calendarName}.ics`); const jsonFilePath = path.join(MERGED_CALENDARS_DIR, `${calendarName}.json`); + try { + // Check if the .ics file exists + if (fs.existsSync(icsFilePath)) { + const stats = fs.statSync(icsFilePath); + const lastModified = new Date(stats.mtime); + const now = new Date(); + } + } + }); // Serve the merged calendar file