Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use process start time when checking nested directory changes #178

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/DirectoryWatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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;

Expand Down