Skip to content

Commit 1325975

Browse files
authored
Merge pull request #8345 from shirady/nsfs-nc-versioning-delete-object-with-object-id
NC | NSFS | Versioning | Fix Bug 8333 | Delete Object with Version ID | GPFS
2 parents 57cd502 + c65039b commit 1325975

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/sdk/namespace_fs.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,8 @@ class NamespaceFS {
14291429
if (this._is_versioning_suspended()) {
14301430
if (latest_ver_info?.version_id_str === NULL_VERSION_ID) {
14311431
dbg.log1('NamespaceFS._move_to_dest_version suspended: version ID of the latest version is null - the file will be unlinked');
1432-
await native_fs_utils.safe_unlink(fs_context, latest_ver_path, latest_ver_info, gpfs_options, bucket_tmp_dir_path);
1432+
await native_fs_utils.safe_unlink(fs_context, latest_ver_path, latest_ver_info,
1433+
gpfs_options?.delete_version, bucket_tmp_dir_path);
14331434
} else {
14341435
// remove a version (or delete marker) with null version ID from .versions/ (if exists)
14351436
await this._delete_null_version_from_versions_directory(key, fs_context);
@@ -2757,7 +2758,8 @@ class NamespaceFS {
27572758
await this._open_files_gpfs(fs_context, file_path, undefined, undefined, undefined, undefined, true) :
27582759
undefined;
27592760
const bucket_tmp_dir_path = this.get_bucket_tmpdir_full_path();
2760-
await native_fs_utils.safe_unlink(fs_context, file_path, version_info, gpfs_options, bucket_tmp_dir_path);
2761+
await native_fs_utils.safe_unlink(fs_context, file_path, version_info,
2762+
gpfs_options?.delete_version, bucket_tmp_dir_path);
27612763
return { ...version_info, latest: true };
27622764
} else {
27632765
await native_fs_utils.unlink_ignore_enoent(fs_context, file_path);
@@ -2930,7 +2932,8 @@ class NamespaceFS {
29302932
} else {
29312933
// versioning suspended and version_id is null
29322934
dbg.log1('NamespaceFS._delete_latest_version: suspended mode version ID of the latest version is null - file will be unlinked');
2933-
await native_fs_utils.safe_unlink(fs_context, latest_ver_path, latest_ver_info, gpfs_options, bucket_tmp_dir_path);
2935+
await native_fs_utils.safe_unlink(fs_context, latest_ver_path, latest_ver_info,
2936+
gpfs_options?.delete_version, bucket_tmp_dir_path);
29342937
}
29352938
}
29362939
break;

src/test/unit_tests/test_nsfs_versioning_gpfs.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,18 @@ mocha.describe('namespace_fs gpfs- versioning', async function() {
196196
assert.equal(head_res.version_id, latest_version_id);
197197
});
198198

199+
mocha.it('delete object with version id - versioning enabled', async function() {
200+
// 1. put bucket versioning enabled
201+
await ns_obj.set_bucket_versioning('ENABLED', dummy_object_sdk);
202+
// 2. create multiple versions (2)
203+
const key2 = 'my-key-to-delete.txt';
204+
await put_object(dummy_object_sdk, ns_obj, gpfs_bucket, key2);
205+
const put_res2 = await put_object(dummy_object_sdk, ns_obj, gpfs_bucket, key2);
206+
// 3. delete object by version-id
207+
const delete_res = await delete_object(dummy_object_sdk, ns_obj, gpfs_bucket, key, put_res2.version_id);
208+
assert.equal(delete_res.version_id, put_res2.version_id);
209+
});
210+
199211
});
200212

201213
async function put_object(dummy_object_sdk, ns, bucket, key) {

0 commit comments

Comments
 (0)