Comparing version 0.1.4 to 0.1.5
@@ -148,3 +148,3 @@ // fileserver | ||
fileDriver.move(dirPath, req.body.newPath, options, | ||
sendCode(200, req, res, next, formatOutData(req, dirPath))); | ||
sendCode(200, req, res, next, formatOutData(req, req.body.newPath))); | ||
return; | ||
@@ -211,13 +211,5 @@ } | ||
var clobber = req.body.clobber || false; | ||
fileDriver.rmdir(dirPath, clobber, function (err) { | ||
if (err && err.code === 'ENOENT') { | ||
sendCode(404, req, res, next, formatOutData(req, dirPath))(null); | ||
} else if (err && err.code === 'EPERM') { | ||
sendCode(403, req, res, next, formatOutData(req, dirPath))(null); | ||
} else if (err && err.code === 'ENOTDIR') { | ||
sendCode(400, req, res, next, formatOutData(req, dirPath))(null); | ||
} else { | ||
sendCode(200, req, res, next, formatOutData(req, dirPath))(err); | ||
} | ||
}); | ||
fileDriver.rmdir(dirPath, clobber, | ||
sendCode(200, req, res, next, formatOutData(req, dirPath)) | ||
); | ||
}; | ||
@@ -234,13 +226,5 @@ | ||
var dirPath = decodeURI(url.parse(req.url).pathname); | ||
fileDriver.unlink(dirPath, function (err) { | ||
if (err && err.code === 'ENOENT') { | ||
sendCode(404, req, res, next, formatOutData(req, dirPath))(null); | ||
} else if (err && err.code === 'EPERM') { | ||
sendCode(403, req, res, next, formatOutData(req, dirPath))(null); | ||
} else if (err && err.code === 'EISDIR') { | ||
sendCode(400, req, res, next, formatOutData(req, dirPath))(null); | ||
} else { | ||
sendCode(200, req, res, next, formatOutData(req, dirPath))(err); | ||
} | ||
}); | ||
fileDriver.unlink(dirPath, | ||
sendCode(200, req, res, next, formatOutData(req, dirPath)) | ||
); | ||
}; | ||
@@ -262,4 +246,18 @@ | ||
if (err) { | ||
return next(err); | ||
code = 500; | ||
out = err; | ||
if (err.code === 'ENOENT') { | ||
code = 404; | ||
} if (err.code === 'EPERM') { | ||
code = 403; | ||
} if (err.code === 'ENOTDIR' || err.code === 'EISDIR') { | ||
code = 400; | ||
} if (err.code === 'ENOTEMPTY' || | ||
err.code === 'EEXIST' || | ||
err.code === 'EINVAL') { | ||
code = 409; | ||
} | ||
} | ||
res.status(code).send(out); | ||
@@ -266,0 +264,0 @@ }; |
{ | ||
"name": "rest-fs", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "restful fileserver", | ||
@@ -5,0 +5,0 @@ "main": "fileserver.js", |
@@ -308,3 +308,3 @@ var Lab = require('lab'); | ||
.del(dir1) | ||
.expect(500) | ||
.expect(409) | ||
.end(function(err, res){ | ||
@@ -311,0 +311,0 @@ if (err) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56626
1591