Skip to content

Commit

Permalink
Optimize listing of keys for data deletion
Browse files Browse the repository at this point in the history
Issue: CLDSRV-570
  • Loading branch information
KillianG committed Nov 18, 2024
1 parent a934fe1 commit e9ae9c2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/api/apiUtils/object/abortMultipartUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,16 @@ function abortMultipartUpload(authInfo, bucketName, objectKey, uploadId, log,
}
// The locations were sent to metadata as an array
// under partLocations. Pull the partLocations.
let locations = storedParts.map(item => item.value.partLocations);
let locations = storedParts.flatMap(item => item.value.partLocations);
if (locations.length === 0) {
return next(null, mpuBucket, storedParts, destBucket);
}
// flatten the array
locations = [].concat(...locations);

const existingLocations = new Set(locations.map(loc => loc.key));

if (objectMD?.location) {
const objectLocationLeft = objectMD.location.filter(loc =>
!locations.some(existingLoc => existingLoc.key === loc.key));
locations = locations.concat(objectLocationLeft);
const remainingObjectLocations = objectMD.location.filter(loc => !existingLocations.has(loc.key));
locations = [...locations, ...remainingObjectLocations];
}

return async.eachLimit(locations, 5, (loc, cb) => {
Expand Down

0 comments on commit e9ae9c2

Please sign in to comment.