Remove file from watched when deleted

This commit is contained in:
Christopher Cookman 2023-10-01 18:04:16 -06:00
parent a40b91282a
commit 7728fab3f3
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -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}!`);