Skip to content

Commit 827e3f1

Browse files
committed
Changed the list of files that are already being
watched by the watcher to use counters instead of flags
1 parent d8e9e06 commit 827e3f1

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

server/cloud9/ext/watcher/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ sys.inherits(cloud9WatcherPlugin, Plugin);
3333
(function() {
3434
this.unwatchFile = function(filename) {
3535
// console.log("No longer watching file " + filename);
36-
delete this.filenames[filename];
37-
fs.unwatchFile(filename);
36+
if (--this.filenames[filename] == 0) {
37+
delete this.filenames[filename];
38+
fs.unwatchFile(filename);
39+
}
3840
return true;
3941
};
4042

41-
// TODO: this does not look correct. There could be more than one client be
42-
// attached. There needs to be a per client list with ref counting
4343
this.disconnect = function() {
4444
for (var filename in this.filenames)
4545
this.unwatchFile(filename);
@@ -58,7 +58,7 @@ sys.inherits(cloud9WatcherPlugin, Plugin);
5858
switch (type) {
5959
case "watchFile":
6060
if (this.filenames[path])
61-
; // console.log("Already watching file " + path);
61+
++this.filenames[path]; // console.log("Already watching file " + path);
6262
else {
6363
// console.log("Watching file " + path);
6464
that = this;
@@ -100,7 +100,7 @@ sys.inherits(cloud9WatcherPlugin, Plugin);
100100
}));
101101
console.log("Sent " + subtype + " notification for file " + path);
102102
});
103-
this.filenames[path] = path;
103+
this.filenames[path] = 0;
104104
}
105105
return true;
106106
case "unwatchFile":

0 commit comments

Comments
 (0)