From 7585f14b8928af6538a1bdbfe990c3061837bda9 Mon Sep 17 00:00:00 2001 From: Ben Hardill Date: Fri, 28 May 2021 08:34:08 +0100 Subject: [PATCH] Watch node throws errors if new files deleted before the node has finished processing them all. Fixes #2996 --- .../@node-red/nodes/core/storage/23-watch.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/node_modules/@node-red/nodes/core/storage/23-watch.js b/packages/node_modules/@node-red/nodes/core/storage/23-watch.js index e43317bb4..9b6c4bc62 100644 --- a/packages/node_modules/@node-red/nodes/core/storage/23-watch.js +++ b/packages/node_modules/@node-red/nodes/core/storage/23-watch.js @@ -23,9 +23,13 @@ module.exports = function(RED) { var getAllDirs = function (dir, filelist) { filelist = filelist || []; fs.readdirSync(dir).forEach(file => { - if (fs.statSync(path.join(dir, file)).isDirectory() ) { - filelist.push(path.join(dir, file)); - getAllDirs(path.join(dir, file), filelist); + try { + if (fs.statSync(path.join(dir, file)).isDirectory() ) { + filelist.push(path.join(dir, file)); + getAllDirs(path.join(dir, file), filelist); + } + } catch (error) { + //should we raise an error? } }); return filelist;