Merge pull request #244 from cory-newleaf/patch-1
Updated "getFile" to send 404 for ENOENT errors
This commit is contained in:
commit
7fec4b8932
|
@ -210,6 +210,10 @@ StorageService.prototype.getFiles = function(container, options, cb) {
|
||||||
*/
|
*/
|
||||||
StorageService.prototype.getFile = function(container, file, cb) {
|
StorageService.prototype.getFile = function(container, file, cb) {
|
||||||
return this.client.getFile(container, file, function(err, f) {
|
return this.client.getFile(container, file, function(err, f) {
|
||||||
|
if (err && err.code === 'ENOENT') {
|
||||||
|
err.statusCode = err.status = 404;
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
return cb(err, map(f));
|
return cb(err, map(f));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -196,6 +196,15 @@ describe('FileSystem based storage provider', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not get a file from a container', function(done) {
|
||||||
|
client.getFile('c1', 'f2.txt', function(err, f) {
|
||||||
|
assert(err);
|
||||||
|
assert.equal('ENOENT', err.code);
|
||||||
|
assert(!f);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should destroy a container c1', function(done) {
|
it('should destroy a container c1', function(done) {
|
||||||
client.destroyContainer('c1', function(err, container) {
|
client.destroyContainer('c1', function(err, container) {
|
||||||
// console.error(err);
|
// console.error(err);
|
||||||
|
|
|
@ -133,6 +133,16 @@ describe('Storage service', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not get a file from a container', function(done) {
|
||||||
|
storageService.getFile('c1', 'f1.txt', function(err, f) {
|
||||||
|
assert(err);
|
||||||
|
assert.equal('ENOENT', err.code);
|
||||||
|
assert.equal(404, err.status);
|
||||||
|
assert(!f);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should destroy a container c1', function(done) {
|
it('should destroy a container c1', function(done) {
|
||||||
storageService.destroyContainer('c1', function(err, container) {
|
storageService.destroyContainer('c1', function(err, container) {
|
||||||
// console.error(err);
|
// console.error(err);
|
||||||
|
@ -142,4 +152,3 @@ describe('Storage service', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue