Skip to content

Commit

Permalink
Fix complete MPU with missing parts
Browse files Browse the repository at this point in the history
Issue: CLDSRV-570
  • Loading branch information
KillianG committed Oct 29, 2024
1 parent ec2e304 commit a30b1c6
Showing 1 changed file with 29 additions and 31 deletions.
60 changes: 29 additions & 31 deletions lib/api/completeMultipartUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ function completeMultipartUpload(authInfo, request, log, callback) {
// if x-scal-s3-version-id header is specified, we overwrite the object/version metadata.
if (isPutVersion) {
const options = overwritingVersioning(objMD, metaStoreParams);
return process.nextTick(() => next(null, destBucket, dataLocations,
return process.nextTick(() => next(null, destBucket, extraPartLocations, dataLocations,
metaStoreParams, mpuBucket, keysToDelete, aggregateETag,
objMD, extraPartLocations, pseudoCipherBundle,
objMD, pseudoCipherBundle,
completeObjData, options));
}
return versioningPreprocessing(bucketName,
Expand All @@ -384,16 +384,32 @@ function completeMultipartUpload(authInfo, request, log, callback) {
});
return next(err, destBucket);
}
return next(null, destBucket, dataLocations,
return next(null, destBucket, extraPartLocations, dataLocations,
metaStoreParams, mpuBucket, keysToDelete, aggregateETag,
objMD, extraPartLocations, pseudoCipherBundle,
completeObjData, options);
objMD, pseudoCipherBundle, completeObjData, options);
});
},
function batchDeleteExtraParts(destinationBucket, extraPartLocations,
dataLocations, metaStoreParams, mpuBucket, keysToDelete,
aggregateETag, objMD, pseudoCipherBundle, completeObjData, options, next) {
if (extraPartLocations && extraPartLocations.length > 0) {
return data.batchDelete(extraPartLocations, request.method, null, log,
err => {
if (err) {
return next(err);
}
return next(null, destinationBucket,
dataLocations, metaStoreParams, mpuBucket, keysToDelete,
aggregateETag, objMD, pseudoCipherBundle, completeObjData, options);
});
}
return next(null, destinationBucket, dataLocations, metaStoreParams,
mpuBucket, keysToDelete, aggregateETag, objMD, pseudoCipherBundle,
completeObjData, options);
},
function storeAsNewObj(destinationBucket, dataLocations,
metaStoreParams, mpuBucket, keysToDelete, aggregateETag, objMD,
extraPartLocations, pseudoCipherBundle,
completeObjData, options, next) {
pseudoCipherBundle, completeObjData, options, next) {
const dataToDelete = options.dataToDelete;
/* eslint-disable no-param-reassign */
metaStoreParams.versionId = options.versionId;
Expand Down Expand Up @@ -442,10 +458,9 @@ function completeMultipartUpload(authInfo, request, log, callback) {
objectKey: metaStoreParams.objectKey,
uploadId: metaStoreParams.uploadId,
});
// pass the original version ID as generatedVersionId
return next(null, mpuBucket, keysToDelete, aggregateETag,
extraPartLocations, destinationBucket,
// pass the original version ID as generatedVersionId
objMD.versionId);
destinationBucket, objMD.versionId);
}
}
return services.metadataStoreObject(destinationBucket.getName(),
Expand Down Expand Up @@ -481,36 +496,19 @@ function completeMultipartUpload(authInfo, request, log, callback) {
return next(err);
}
return next(null, mpuBucket, keysToDelete,
aggregateETag, extraPartLocations,
destinationBucket, generatedVersionId);
aggregateETag, destinationBucket, generatedVersionId);
});
}
return next(null, mpuBucket, keysToDelete, aggregateETag,
extraPartLocations, destinationBucket,
generatedVersionId);
destinationBucket, generatedVersionId);
});
},
function deletePartsMetadata(mpuBucket, keysToDelete, aggregateETag,
extraPartLocations, destinationBucket, generatedVersionId, next) {
destinationBucket, generatedVersionId, next) {
services.batchDeleteObjectMetadata(mpuBucket.getName(),
keysToDelete, log, err => next(err, extraPartLocations,
keysToDelete, log, err => next(err,
destinationBucket, aggregateETag, generatedVersionId));
},
function batchDeleteExtraParts(extraPartLocations, destinationBucket,
aggregateETag, generatedVersionId, next) {
if (extraPartLocations && extraPartLocations.length > 0) {
return data.batchDelete(extraPartLocations, request.method,
null, log, err => {
if (err) {
return next(err);
}
return next(null, destinationBucket, aggregateETag,
generatedVersionId);
});
}
return next(null, destinationBucket, aggregateETag,
generatedVersionId);
},
], (err, destinationBucket, aggregateETag, generatedVersionId) => {
const corsHeaders =
collectCorsHeaders(request.headers.origin, request.method,
Expand Down

0 comments on commit a30b1c6

Please sign in to comment.