Skip to content

Commit

Permalink
fix for complete MPU
Browse files Browse the repository at this point in the history
  • Loading branch information
williamlardier committed Oct 25, 2024
1 parent ec2e304 commit 7fa90d6
Showing 1 changed file with 33 additions and 40 deletions.
73 changes: 33 additions & 40 deletions lib/api/completeMultipartUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,13 +367,11 @@ 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,
metaStoreParams, mpuBucket, keysToDelete, aggregateETag,
objMD, extraPartLocations, pseudoCipherBundle,
completeObjData, options));
return process.nextTick(() => next(null, destBucket, extraPartLocations,
dataLocations, metaStoreParams, mpuBucket, keysToDelete,
aggregateETag, objMD, pseudoCipherBundle, completeObjData, options));
}
return versioningPreprocessing(bucketName,
destBucket, objectKey, objMD, log, (err, options) => {
return versioningPreprocessing(bucketName, destBucket, objectKey, objMD, log, (err, options) => {
if (err) {
// TODO: check AWS error when user requested a specific
// version before any versions have been put
Expand All @@ -384,15 +382,31 @@ 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 storeAsNewObj(destinationBucket, dataLocations,
metaStoreParams, mpuBucket, keysToDelete, aggregateETag, objMD,
extraPartLocations, pseudoCipherBundle,
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(errors.InternalError.customizeDescription('test1'), destinationBucket,
dataLocations, metaStoreParams, mpuBucket, keysToDelete,
aggregateETag, objMD, extraPartLocations, pseudoCipherBundle, completeObjData, options);
});
}
return next(null, destinationBucket, dataLocations, metaStoreParams,
mpuBucket, keysToDelete, aggregateETag, objMD, extraPartLocations, pseudoCipherBundle,
completeObjData, options);
},
function storeAsNewObj(destinationBucket, dataLocations, metaStoreParams,
mpuBucket, keysToDelete, aggregateETag, objMD, extraPartLocations, pseudoCipherBundle,
completeObjData, options, next) {
const dataToDelete = options.dataToDelete;
/* eslint-disable no-param-reassign */
Expand Down Expand Up @@ -443,9 +457,7 @@ function completeMultipartUpload(authInfo, request, log, callback) {
uploadId: metaStoreParams.uploadId,
});
return next(null, mpuBucket, keysToDelete, aggregateETag,
extraPartLocations, destinationBucket,
// pass the original version ID as generatedVersionId
objMD.versionId);
extraPartLocations, destinationBucket, objMD.versionId);
}
}
return services.metadataStoreObject(destinationBucket.getName(),
Expand Down Expand Up @@ -474,42 +486,23 @@ function completeMultipartUpload(authInfo, request, log, callback) {
const newDataStoreName =
Array.isArray(dataLocations) && dataLocations[0] ?
dataLocations[0].dataStoreName : null;
return data.batchDelete(dataToDelete,
request.method,
return data.batchDelete(dataToDelete, request.method,
newDataStoreName, log, err => {
if (err) {
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) {
services.batchDeleteObjectMetadata(mpuBucket.getName(),
keysToDelete, log, err => next(err, extraPartLocations,
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);
destinationBucket, generatedVersionId, next) {
services.batchDeleteObjectMetadata(mpuBucket.getName(), keysToDelete, log,
err => next(err, destinationBucket, aggregateETag, generatedVersionId));
},
], (err, destinationBucket, aggregateETag, generatedVersionId) => {
const corsHeaders =
Expand Down

0 comments on commit 7fa90d6

Please sign in to comment.