From 7728fab3f36151ff3231dfee05b478cc6e618f54 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Sun, 1 Oct 2023 18:04:16 -0600 Subject: [PATCH] Remove file from watched when deleted --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 3316b2a..fd86b0c 100644 --- a/index.js +++ b/index.js @@ -94,10 +94,6 @@ const watcher = chokidar.watch(config.freepbx.voicemaildir, { persistent: true }); -watcher.on('all', (event, path) => { - console.log(event, path); -}); - watched = []; watcher.on("add", async (filePath, stats) => { if (startup) return; @@ -139,6 +135,10 @@ watcher.on("add", async (filePath, stats) => { }) }); +watcher.on('unlink', (filePath) => { + watched.splice(watched.indexOf(filePath), 1); +}); + // Setup Discord bot client.on("ready", async () => { console.log(`Logged in as ${client.user.tag}!`);