kopia lustrzana https://github.com/c9/core
add back client side watcher handling for rename
rodzic
d07f5e1feb
commit
7b9bd4ef2a
|
@ -46,10 +46,29 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function unwatchChildren(e) {
|
||||||
|
e.watchers = [];
|
||||||
|
Object.keys(handlers).forEach(function(path) {
|
||||||
|
if (path == e.path || path.startsWith(e.path + "/")) {
|
||||||
|
if (unwatch(path))
|
||||||
|
e.watchers.push(path.slice(e.path.length));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ignoreHandler(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
function rewatchChildren(e) {
|
||||||
|
doneHandler(e);
|
||||||
|
var toPath = e.result[0] ? e.path : e.args[1];
|
||||||
|
e.watchers.forEach(function(path) {
|
||||||
|
watch(toPath + path);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
fs.on("beforeWriteFile", ignoreHandler, plugin);
|
fs.on("beforeWriteFile", ignoreHandler, plugin);
|
||||||
fs.on("afterWriteFile", doneHandler, plugin);
|
fs.on("afterWriteFile", doneHandler, plugin);
|
||||||
fs.on("beforeRename", ignoreHandler, plugin);
|
fs.on("beforeRename", unwatchChildren, plugin);
|
||||||
fs.on("afterRename", doneHandler, plugin);
|
fs.on("afterRename", rewatchChildren, plugin);
|
||||||
fs.on("beforeMkdir", ignoreHandler, plugin);
|
fs.on("beforeMkdir", ignoreHandler, plugin);
|
||||||
fs.on("afterMkdir", doneHandler, plugin);
|
fs.on("afterMkdir", doneHandler, plugin);
|
||||||
fs.on("beforeMkdirP", ignoreHandler, plugin);
|
fs.on("beforeMkdirP", ignoreHandler, plugin);
|
||||||
|
|
Ładowanie…
Reference in New Issue