Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
copy: function(source, destination, callback) {
var self = this;
source = this.getRealPath(source);
destination = this.getRealPath(destination);
if (!this.insideSandbox(destination)) {
return callback(new Exc.Forbidden("You are not allowed to copy to " +
this.stripSandbox(destination)));
}
// first check if source exists
this.vfs.stat(source, {}, function(err, stat) {
if (err || stat.err)
return callback(err);
// if destination exists try to delete it
self.vfs.rmdir(destination, { recursive: true }, function(err) {
// ignore error because destination may not exists
self.vfs.execFile("cp", {args: ["-R", source, destination]}, callback);
});
});
},
this.vfs.mkfile(path, {}, function(err, meta) {
if (err) {
if (err.code == "EACCES")
err = new Exc.Forbidden("Permission denied to write file:" + path);
return callback(err);
}
handler.getRequestBody(type, meta.stream, false, callback);
});
}