Skip to content

Commit 19f68c0

Browse files
authored
Merge pull request #8491 from shirady/nsfs-nc-put-object-error
NC | NSFS | Versioning | Avoid Errors On Put Object of Directory Content
2 parents 8171306 + 3120d3d commit 19f68c0

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/sdk/namespace_fs.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ class NamespaceFS {
13881388
dbg.log1('NamespaceFS._finish_upload:', open_mode, file_path, upload_path, fs_xattr);
13891389

13901390
if (!same_inode && !part_upload) {
1391-
await this._move_to_dest(fs_context, upload_path, file_path, target_file, open_mode, params.key);
1391+
await this._move_to_dest(fs_context, upload_path, file_path, target_file, open_mode, params.key, is_dir_content);
13921392
}
13931393

13941394
// when object is a dir, xattr are set on the folder itself and the content is in .folder file
@@ -1421,13 +1421,16 @@ class NamespaceFS {
14211421
}
14221422

14231423
// move to dest GPFS (wt) / POSIX (w / undefined) - non part upload
1424-
async _move_to_dest(fs_context, source_path, dest_path, target_file, open_mode, key) {
1424+
async _move_to_dest(fs_context, source_path, dest_path, target_file, open_mode, key, is_dir_content) {
1425+
dbg.log2('_move_to_dest', fs_context, source_path, dest_path, target_file, open_mode, key, is_dir_content);
14251426
let retries = config.NSFS_RENAME_RETRIES;
14261427
// will retry renaming a file in case of parallel deleting of the destination path
14271428
for (;;) {
14281429
try {
14291430
await native_fs_utils._make_path_dirs(dest_path, fs_context);
1430-
if (this._is_versioning_disabled()) {
1431+
if (this._is_versioning_disabled() ||
1432+
(this._is_versioning_enabled() && is_dir_content)) {
1433+
// dir_content is not supported in versioning, hence we will treat it like versioning disabled
14311434
if (open_mode === 'wt') {
14321435
await target_file.linkfileat(fs_context, dest_path);
14331436
} else {

src/test/unit_tests/test_bucketspace_versioning.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,21 @@ mocha.describe('bucketspace namespace_fs - versioning', function() {
339339
}
340340
assert.deepEqual(res_version_ids, res_put_version_ids);
341341
});
342+
343+
// dir_content is not supported in versioning, but we want to make sure there are no errors
344+
mocha.it('put object - versioning enabled - directory content', async function() {
345+
await s3_uid6.putBucketVersioning({ Bucket: nested_keys_bucket_name, VersioningConfiguration: { MFADelete: 'Disabled', Status: 'Enabled' } });
346+
const key_as_dir_content = '/a/b/c/';
347+
const size = 4; // in the original issue the error started on the 3rd PUT of dir content
348+
const res_put_object = [];
349+
for (let i = 0; i < size; i++) {
350+
const res = await s3_uid6.putObject({ Bucket: nested_keys_bucket_name, Key: key_as_dir_content, Body: body1 });
351+
res_put_object.push(res);
352+
}
353+
assert(res_put_object.length === size);
354+
const check_version_id_exists = res_put_object.every(res => res.VersionId !== undefined);
355+
assert.ok(check_version_id_exists);
356+
});
342357
});
343358

344359
mocha.describe('mpu object', function() {

0 commit comments

Comments
 (0)