Skip to content

Commit

Permalink
Fix delete object MD with version ID
Browse files Browse the repository at this point in the history
Issue: CLDSRV-570
  • Loading branch information
KillianG committed Nov 15, 2024
1 parent f7c4f97 commit de934fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 6 additions & 4 deletions lib/api/apiUtils/object/abortMultipartUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ function abortMultipartUpload(authInfo, bucketName, objectKey, uploadId, log,
method: 'abortMultipartUpload',
bucketName,
objectKey,
uploadId,
versionId: objectMD.versionId
});
return metadata.deleteObjectMD(bucketName, objectKey, undefined, log, err => {
return metadata.deleteObjectMD(bucketName, objectKey, {versionId: objectMD.versionId}, log, err => {
if (err) {
log.error('error deleting object metadata', { error: err });
}
Expand All @@ -138,9 +140,9 @@ function abortMultipartUpload(authInfo, bucketName, objectKey, uploadId, log,
return next(null, mpuBucket, storedParts, destBucket);
}
// Filtering parts that has already been delete by the previous step
let partLocations = storedParts.map(item => item.value.partLocations);
partLocations = [].concat(...partLocations);
partLocations = new Set(partLocations.map(loc => loc.key));
const partLocations = new Set(
storedParts.flatMap(item => item.value.partLocations.map(loc => loc.key))
);
const objectLocationLeft = objectMD.location.filter(loc => !partLocations.has(loc.key));

return async.eachLimit(objectLocationLeft, 5, (loc, cb) => {
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/api/multipartUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -2048,8 +2048,7 @@ describe('Multipart Upload API', () => {
completeMultipartUpload(authInfo,
completeRequest, log, err => {
assert(err.is.InternalError);
const MD = metadata.keyMaps.get(bucketName)
.get(objectKey);
const MD = metadata.keyMaps.get(bucketName).get(objectKey);
assert(MD);
assert.strictEqual(MD['x-amz-meta-stuff'],
'I am some user metadata');
Expand Down

0 comments on commit de934fa

Please sign in to comment.