Skip to content

Commit

Permalink
Don't emit unlink on previously removed paths
Browse files Browse the repository at this point in the history
Resolves gh-236
  • Loading branch information
es128 committed Feb 23, 2015
1 parent c5cf1e5 commit 65b5206
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,17 @@ FSWatcher.prototype._remove = function(directory, item) {
this._remove(path, nestedItem);
}, this);

// Remove directory / file from watched list.
this._getWatchedDir(directory).remove(item);
// Check if item was on the watched list and remove it
var parent = this._getWatchedDir(directory);
var wasTracked = parent.has(item);
parent.remove(item);

// The Entry will either be a directory that just got removed
// or a bogus entry to a file, in either case we have to remove it
delete this._watched[path];
delete this._watched[fullPath];
var eventName = isDirectory ? 'unlinkDir' : 'unlink';
if (!this._isIgnored(path)) this._emit(eventName, path);
if (wasTracked && !this._isIgnored(path)) this._emit(eventName, path);
};

// Public method: Adds paths to be watched on an existing FSWatcher instance
Expand Down

0 comments on commit 65b5206

Please sign in to comment.