diff --git a/src/sdk/namespace_fs.js b/src/sdk/namespace_fs.js index f825ca0225..60b49d32f3 100644 --- a/src/sdk/namespace_fs.js +++ b/src/sdk/namespace_fs.js @@ -1388,7 +1388,7 @@ class NamespaceFS { dbg.log1('NamespaceFS._finish_upload:', open_mode, file_path, upload_path, fs_xattr); if (!same_inode && !part_upload) { - await this._move_to_dest(fs_context, upload_path, file_path, target_file, open_mode, params.key); + await this._move_to_dest(fs_context, upload_path, file_path, target_file, open_mode, params.key, is_dir_content); } // 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 { } // move to dest GPFS (wt) / POSIX (w / undefined) - non part upload - async _move_to_dest(fs_context, source_path, dest_path, target_file, open_mode, key) { + async _move_to_dest(fs_context, source_path, dest_path, target_file, open_mode, key, is_dir_content) { + dbg.log2('_move_to_dest', fs_context, source_path, dest_path, target_file, open_mode, key, is_dir_content); let retries = config.NSFS_RENAME_RETRIES; // will retry renaming a file in case of parallel deleting of the destination path for (;;) { try { await native_fs_utils._make_path_dirs(dest_path, fs_context); - if (this._is_versioning_disabled()) { + if (this._is_versioning_disabled() || + (this._is_versioning_enabled() && is_dir_content)) { + // dir_content is not supported in versioning, hence we will treat it like versioning disabled if (open_mode === 'wt') { await target_file.linkfileat(fs_context, dest_path); } else { diff --git a/src/test/unit_tests/test_bucketspace_versioning.js b/src/test/unit_tests/test_bucketspace_versioning.js index a02e6ec1a2..9f3cab657a 100644 --- a/src/test/unit_tests/test_bucketspace_versioning.js +++ b/src/test/unit_tests/test_bucketspace_versioning.js @@ -339,6 +339,21 @@ mocha.describe('bucketspace namespace_fs - versioning', function() { } assert.deepEqual(res_version_ids, res_put_version_ids); }); + + // dir_content is not supported in versioning, but we want to make sure there are no errors + mocha.it('put object - versioning enabled - directory content', async function() { + await s3_uid6.putBucketVersioning({ Bucket: nested_keys_bucket_name, VersioningConfiguration: { MFADelete: 'Disabled', Status: 'Enabled' } }); + const key_as_dir_content = '/a/b/c/'; + const size = 4; // in the original issue the error started on the 3rd PUT of dir content + const res_put_object = []; + for (let i = 0; i < size; i++) { + const res = await s3_uid6.putObject({ Bucket: nested_keys_bucket_name, Key: key_as_dir_content, Body: body1 }); + res_put_object.push(res); + } + assert(res_put_object.length === size); + const check_version_id_exists = res_put_object.every(res => res.VersionId !== undefined); + assert.ok(check_version_id_exists); + }); }); mocha.describe('mpu object', function() {