Skip to content

Commit

Permalink
Merge 00683f5 into 8cd5f7a
Browse files Browse the repository at this point in the history
  • Loading branch information
laggingreflex committed Aug 14, 2018
2 parents 8cd5f7a + 00683f5 commit 6fa482d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ FSWatcher.prototype.close = function() {

this.closed = true;
Object.keys(this._closers).forEach(function(watchPath) {
this._closers[watchPath]();
this._closers[watchPath](true);
delete this._closers[watchPath];
}, this);
this._watched = Object.create(null);
Expand Down
11 changes: 7 additions & 4 deletions lib/nodefs-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,14 @@ function setFsWatchListener(path, fullPath, options, handlers) {

// removes this instance's listeners and closes the underlying fs.watch
// instance if there are no more listeners left
return function close() {
return function close(force) {
delete container.listeners[listenerIndex];
delete container.errHandlers[listenerIndex];
delete container.rawEmitters[listenerIndex];
if (!Object.keys(container.listeners).length) {
if (force) {
container.watcher.close();
delete FsWatchInstances[fullPath];
} else if (!Object.keys(container.listeners).length) {
if (!container.watcherUnusable) { // check to protect against issue #730
container.watcher.close();
}
Expand Down Expand Up @@ -190,10 +193,10 @@ function setFsWatchFileListener(path, fullPath, options, handlers) {

// removes this instance's listeners and closes the underlying fs.watchFile
// instance if there are no more listeners left
return function close() {
return function close(force) {
delete container.listeners[listenerIndex];
delete container.rawEmitters[listenerIndex];
if (!Object.keys(container.listeners).length) {
if (force || !Object.keys(container.listeners).length) {
fs.unwatchFile(fullPath);
delete FsWatchFileInstances[fullPath];
}
Expand Down

0 comments on commit 6fa482d

Please sign in to comment.