From 38fac42a0d75ca83869a78d0368f4a2804a93f47 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 27 Feb 2015 18:43:20 +0400 Subject: [PATCH] revert watcher changes causing memory leak --- node_modules/vfs-local/localfs.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/node_modules/vfs-local/localfs.js b/node_modules/vfs-local/localfs.js index f5262624..cfbd0aac 100644 --- a/node_modules/vfs-local/localfs.js +++ b/node_modules/vfs-local/localfs.js @@ -1380,23 +1380,21 @@ module.exports = function setup(fsOptions) { }); callback(done); - function loop(watchers, path, event, callback) { + function done(callback) { if (!watchers.length) return callback(); - + + // Notify each watcher of changes and reactivate it var watcher = watchers.pop(); - watcher.handleWatchEvent(event, basename(path), true); - + fs.stat(path, function(err, stat) { + if (err || !stat) return; + stat.vfsWrite = true; + watcher.sendToAllListeners("change", basename(path), stat); + }); watcher.resume(function() { - loop(watchers, path, event, callback); + done(callback); }); } - - function done(callback) { - loop(watchers, path, "change", function() { - loop(dirWatchers, parentDir, "directory", callback); - }); - } } function connect(port, options, callback) {