From 46c763b64c903a067f34e3f6b9c1d12b52700726 Mon Sep 17 00:00:00 2001 From: Karlis Gangis Date: Thu, 29 Oct 2020 19:47:58 +0200 Subject: [PATCH] use process start time when checking nested directory changes --- lib/DirectoryWatcher.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/DirectoryWatcher.js b/lib/DirectoryWatcher.js index 30aa66c..a2be1b3 100644 --- a/lib/DirectoryWatcher.js +++ b/lib/DirectoryWatcher.js @@ -12,6 +12,8 @@ const watchEventSource = require("./watchEventSource"); const EXISTANCE_ONLY_TIME_ENTRY = Object.freeze({}); +const processStartTime = Date.now() - process.uptime() * 1000 - 1000; + let FS_ACCURACY = 1000; const IS_OSX = require("os").platform() === "darwin"; @@ -278,7 +280,10 @@ class DirectoryWatcher extends EventEmitter { } createNestedWatcher(directoryPath) { - const watcher = this.watcherManager.watchDirectory(directoryPath, 1); + const watcher = this.watcherManager.watchDirectory( + directoryPath, + processStartTime + ); watcher.on("change", (filePath, mtime, type, initial) => { this._cachedTimeInfoEntries = undefined; this.forEachWatcher(this.path, w => { @@ -500,7 +505,10 @@ class DirectoryWatcher extends EventEmitter { // removing directories in the root directory is not supported if (path.dirname(parentDir) === parentDir) return; - this.parentWatcher = this.watcherManager.watchFile(this.path, 1); + this.parentWatcher = this.watcherManager.watchFile( + this.path, + processStartTime + ); this.parentWatcher.on("change", (mtime, type) => { if (this.closed) return;