#4: Return a 404 if file doesn't exist
Signed-off-by: Timo Saikkonen <timo.saikkonen@gmail.com>
This commit is contained in:
parent
58b69236bb
commit
169ee1be21
|
@ -118,9 +118,16 @@ exports.download = function (provider, req, res, container, file, cb) {
|
|||
container: container || req && req.params.container,
|
||||
remote: file || req && req.params.file
|
||||
});
|
||||
|
||||
res.type(file);
|
||||
reader.pipe(res);
|
||||
reader.on('error', function (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
res.type('application/json');
|
||||
res.send(404, { error: err });
|
||||
return;
|
||||
}
|
||||
|
||||
res.type('application/json');
|
||||
res.send(500, { error: err });
|
||||
});
|
||||
|
|
|
@ -92,6 +92,10 @@ StorageService.prototype.destroyContainer = function (container, cb) {
|
|||
*/
|
||||
StorageService.prototype.getContainer = function (container, cb) {
|
||||
return this.client.getContainer(container, function (err, container) {
|
||||
if (err && err.code === 'ENOENT') {
|
||||
err.statusCode = err.status = 404;
|
||||
return cb(err);
|
||||
}
|
||||
return cb(err, map(container));
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue