Skip to content

Commit f5e2803

Browse files
authored
Merge pull request #9040 from achouhan09/temp-dir-fix
Added a fix to not include the temp dir in list objects
2 parents 35bfb70 + 711b378 commit f5e2803

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/sdk/namespace_fs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ class NamespaceFS {
767767
// dbg.log0('process_entry', dir_key, ent.name);
768768
if (!ent.name.startsWith(prefix_ent) ||
769769
ent.name < marker_curr ||
770-
ent.name === this.get_bucket_tmpdir_name() ||
770+
ent.name.startsWith(config.NSFS_TEMP_DIR_NAME) ||
771771
(ent.name === config.NSFS_FOLDER_OBJECT_NAME && is_disabled_dir_content) ||
772772
this._is_hidden_version_path(ent.name)) {
773773
return;

src/test/unit_tests/test_ns_list_objects.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
const mocha = require('mocha');
55
const assert = require('assert');
6+
const config = require('../../../config');
67

78
const buffer_utils = require('../../util/buffer_utils');
9+
const fs_utils = require('../../util/fs_utils');
810

911
// eslint-disable-next-line max-lines-per-function
1012
function test_ns_list_objects(ns, object_sdk, bucket) {
@@ -313,6 +315,33 @@ function test_ns_list_objects(ns, object_sdk, bucket) {
313315
});
314316
});
315317

318+
mocha.describe('list objects - hidden dir', function() {
319+
320+
this.timeout(10 * 60 * 1000); // eslint-disable-line no-invalid-this
321+
322+
const hidden_dir_bkt = 'test_ns_hidder_dir';
323+
const dummy_file1 = 'dummy1';
324+
const dummy_file2 = 'dummy2';
325+
const hidden_dir = config.NSFS_TEMP_DIR_NAME + '-buck_id';
326+
327+
mocha.before(async function() {
328+
fs_utils.create_fresh_path(`${ns.bucket_path}/${hidden_dir}`); // creating new hidden dir starting with .noobaa-nsfs
329+
await create_keys([dummy_file1, dummy_file2]);
330+
});
331+
mocha.after(async function() {
332+
await delete_keys([dummy_file1, dummy_file2]);
333+
});
334+
335+
mocha.it('should not list the hidden/internal dir as common_prefixes', async function() {
336+
const r = await ns.list_objects({
337+
bucket: hidden_dir_bkt,
338+
delimiter: '/'
339+
}, object_sdk);
340+
assert.deepStrictEqual(r.is_truncated, false);
341+
assert.deepStrictEqual(r.common_prefixes, []);
342+
assert.deepStrictEqual(r.objects.length, 2);
343+
});
344+
});
316345
mocha.describe('max keys test', function() {
317346

318347
this.timeout(10 * 60 * 1000); // eslint-disable-line no-invalid-this

0 commit comments

Comments
 (0)