diff --git a/node_modules/vfs-local/localfs.js b/node_modules/vfs-local/localfs.js index d1c2a1b6..92ffd2c9 100644 --- a/node_modules/vfs-local/localfs.js +++ b/node_modules/vfs-local/localfs.js @@ -429,8 +429,17 @@ module.exports = function setup(fsOptions) { var meta = {}; resolvePath(path, options, function (err, realpath) { if (err) return callback(err); - fn(realpath, function (err) { - if (err) return callback(err); + fn(realpath, function done(err) { + if (err) { + if (err.code == "ENOENT") { + return fs.exists(realpath, function(exists) { + if (exists) err.code = "EACCES"; + callback(err); + }); + } else { + return callback(err); + } + } // Remove metadata resolvePath(WSMETAPATH + path, options, function (err, realpath) { @@ -1003,7 +1012,17 @@ module.exports = function setup(fsOptions) { function rmdir(path, options, callback) { if (options.recursive) { remove(path, function(path, callback) { - execFile("rm", {args: ["-rf", path]}, callback); + spawn("rm", {args: ["-rf", path], stdio: 'ignore'}, function(err, child) { + if (err) return callback(err); + child.process.on("close", function(code) { + if (code) { + var err = new Error("Permission denied."); + err.code = "EACCES"; + return callback(err); + } + callback(); + }); + }); }, options, callback); } else { diff --git a/plugins/c9.fs/fs.cache.xml.js b/plugins/c9.fs/fs.cache.xml.js index 6c780202..76843142 100644 --- a/plugins/c9.fs/fs.cache.xml.js +++ b/plugins/c9.fs/fs.cache.xml.js @@ -746,7 +746,7 @@ define(function(require, exports, module) { } else if (node.status == "loading") { plugin.on("readdir", function listener(e) { if (e.path == subPath) { - plugin.on("readdir", listener); + plugin.off("readdir", listener); recur(); } }); diff --git a/plugins/c9.fs/fs.cache.xml_test.js b/plugins/c9.fs/fs.cache.xml_test.js index dd8b93d8..4272450c 100644 --- a/plugins/c9.fs/fs.cache.xml_test.js +++ b/plugins/c9.fs/fs.cache.xml_test.js @@ -462,8 +462,9 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "events"], fs.writeFile(before, text, function(err) { expect(fsCache.findNode(before), "start").to.exist; + expect(fsCache.findNode(after), "start").to.not.exist; fs.rename(before, after, function() { - expect(fsCache.findNode(after), "afer").to.exist; + expect(fsCache.findNode(after), "after").to.exist; expect(fsCache.findNode(before), "before").to.not.exist; fs.rmfile(after, function(){ fsCache.off("update", c1); @@ -486,6 +487,7 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "events"], fsCache.on("update", c1); fs.writeFile(before, text, function(err) { + expect(err).to.not.ok; expect(fsCache.findNode(before), "start").to.exist; fs.rename(before, after, function() { @@ -500,11 +502,10 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "events"], throw new Error("Wrong Event Count: " + count + " of 2"); }); - // Disabled: test fails only on CI server... }); }); }); - it.skip("should recursively update the nodes in cache when a dir is renamed", function(done) { + it("should recursively update the nodes in cache when a dir is renamed", function(done) { fs.rmdir("/rdir", {recursive:true}, function(){ fs.copy("/dir", "/dir2", {recursive: true}, function(err) { if (err) throw err.message; @@ -535,7 +536,7 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "events"], + count + " of 3"); }); }); - }) + }); }); }); }); diff --git a/plugins/c9.fs/fs_test.js b/plugins/c9.fs/fs_test.js index f2a85c8c..64804ad0 100644 --- a/plugins/c9.fs/fs_test.js +++ b/plugins/c9.fs/fs_test.js @@ -18,12 +18,6 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root"], "plugins/c9.vfs.client/endpoint", "plugins/c9.ide.auth/auth", - //Mock Plugins - { - consumes: ["Plugin"], - provides: ["auth.bootstrap", "info", "dialog.error"], - setup: expect.html.mocked - }, { consumes: ["fs"], provides: [], @@ -285,6 +279,8 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root"], expect(exists).ok; fs.rmdir(vpath, {}, function(err, meta) { + if (err.code == "EACCES") // node sends EACCES on windows + err.code = "ENOTDIR"; expect(err).property("code").equal("ENOTDIR"); done(); });