Skip to content

Commit

Permalink
Merge pull request #6525 from jeniawhite/evgb-NSFSErrorCodes
Browse files Browse the repository at this point in the history
Fixing error codes for NSFS
  • Loading branch information
nimrod-becker authored May 25, 2021
2 parents b920b65 + 6bf1668 commit 5a07213
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/sdk/namespace_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,7 @@ class NamespaceFS {
const file_path = this._get_file_path(params);
const stat = await nb_native().fs.stat(fs_account_config, file_path);
console.log(file_path, stat);
if (isDirectory(stat)) {
const err = new Error('NoSuchKey');
err.code = 'ENOENT';
throw this._translate_object_error_codes(err);
}
if (isDirectory(stat)) throw Object.assign(new Error('NoSuchKey'), { code: 'ENOENT' });
return this._get_object_info(params.bucket, params.key, stat);
} catch (err) {
throw this._translate_object_error_codes(err);
Expand Down
14 changes: 14 additions & 0 deletions src/test/unit_tests/test_namespace_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ mocha.describe('namespace_fs', function() {
console.log(inspect(res));
});

mocha.it('read_object_md fails on directory head', async function() {
try {
await ns_src.read_object_md({
bucket: src_bkt,
key: src_key.substr(0, src_key.lastIndexOf('/')),
}, dummy_object_sdk);
throw new Error('Should have failed on head of directory');
} catch (error) {
assert.strict.equal(error.message, 'NoSuchKey');
assert.strict.equal(error.code, 'ENOENT');
assert.strict.equal(error.rpc_code, 'NO_SUCH_OBJECT');
}
});

mocha.describe('read_object_stream', function() {

mocha.it('read full', async function() {
Expand Down

0 comments on commit 5a07213

Please sign in to comment.