From e8a0f726ace7775d6efdecfb7c75007301e5d38d Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 9 Jan 2019 14:12:07 +0100 Subject: [PATCH 1/2] fallback to directory scan when change event without filename occurs --- lib/DirectoryWatcher.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/DirectoryWatcher.js b/lib/DirectoryWatcher.js index f75634e..0aed93a 100644 --- a/lib/DirectoryWatcher.js +++ b/lib/DirectoryWatcher.js @@ -332,6 +332,14 @@ class DirectoryWatcher extends EventEmitter { onWatchEvent(eventType, filename) { if(this.closed) return; + if(!filename) { + // In some cases no filename is provided + // This seem to happen on windows + // So some event happened but we don't know which file is affected + // We have to do a full scan of the directory + this.doScan(false); + return; + } if(this._activeEvents.get(filename) === undefined) { this._activeEvents.set(filename, false); const checkStats = () => { From 3edd5c554e8311345ed945a4f0f3a976b7f29a6a Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 9 Jan 2019 14:20:20 +0100 Subject: [PATCH 2/2] early repeat scan --- lib/DirectoryWatcher.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/DirectoryWatcher.js b/lib/DirectoryWatcher.js index 0aed93a..e7f1314 100644 --- a/lib/DirectoryWatcher.js +++ b/lib/DirectoryWatcher.js @@ -502,6 +502,12 @@ class DirectoryWatcher extends EventEmitter { this.setMissing(file, initial, "scan (missing)"); } } + if(this.scanAgain) { + // Early repeat of scan + this.scanAgain = false; + this.doScan(initial); + return; + } async.forEach(itemPaths, (itemPath, callback) => { fs.stat(itemPath, (err2, stats) => { if(this.closed) return;