Compare commits
1 Commits
master
...
move-versi
Author | SHA1 | Date |
---|---|---|
|
414f0ae0a8 |
lib
|
@ -12,6 +12,12 @@ const versionIdUtils = versioning.VersionID;
|
||||||
const nonVersionedObjId =
|
const nonVersionedObjId =
|
||||||
versionIdUtils.getInfVid(config.replicationGroupId);
|
versionIdUtils.getInfVid(config.replicationGroupId);
|
||||||
|
|
||||||
|
let uidCounter = 0;
|
||||||
|
function generateVersionId() {
|
||||||
|
// generate a unique number for each member of the nodejs cluster
|
||||||
|
return versioning.VersionID.generateVersionId(`${process.pid}.${uidCounter++}`, config.replicationGroupId);
|
||||||
|
}
|
||||||
|
|
||||||
/** decodeVID - decode the version id
|
/** decodeVID - decode the version id
|
||||||
* @param {string} versionId - version ID
|
* @param {string} versionId - version ID
|
||||||
* @return {(Error|string|undefined)} - return Invalid Argument if decryption
|
* @return {(Error|string|undefined)} - return Invalid Argument if decryption
|
||||||
|
@ -556,6 +562,7 @@ function overwritingVersioning(objMD, metadataStoreParams) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
generateVersionId,
|
||||||
decodeVersionId,
|
decodeVersionId,
|
||||||
getVersionIdResHeader,
|
getVersionIdResHeader,
|
||||||
checkQueryVersionId,
|
checkQueryVersionId,
|
||||||
|
|
|
@ -93,19 +93,8 @@ function completeMultipartUpload(authInfo, request, log, callback) {
|
||||||
let oldByteLength = null;
|
let oldByteLength = null;
|
||||||
const responseHeaders = {};
|
const responseHeaders = {};
|
||||||
|
|
||||||
let versionId;
|
if (request.headers['x-scal-s3-version-id']) {
|
||||||
const putVersionId = request.headers['x-scal-s3-version-id'];
|
return callback(new Error('x-scal-s3-version-id is not supported in completeMultipartUpload'));
|
||||||
const isPutVersion = putVersionId || putVersionId === '';
|
|
||||||
if (putVersionId) {
|
|
||||||
const decodedVidResult = decodeVID(putVersionId);
|
|
||||||
if (decodedVidResult instanceof Error) {
|
|
||||||
log.trace('invalid x-scal-s3-version-id header', {
|
|
||||||
versionId: putVersionId,
|
|
||||||
error: decodedVidResult,
|
|
||||||
});
|
|
||||||
return process.nextTick(() => callback(decodedVidResult));
|
|
||||||
}
|
|
||||||
versionId = decodedVidResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const queryContainsVersionId = checkQueryVersionId(request.query);
|
const queryContainsVersionId = checkQueryVersionId(request.query);
|
||||||
|
@ -133,7 +122,6 @@ function completeMultipartUpload(authInfo, request, log, callback) {
|
||||||
// Required permissions for this action
|
// Required permissions for this action
|
||||||
// at the destinationBucket level are same as objectPut
|
// at the destinationBucket level are same as objectPut
|
||||||
requestType: request.apiMethods || 'completeMultipartUpload',
|
requestType: request.apiMethods || 'completeMultipartUpload',
|
||||||
versionId,
|
|
||||||
request,
|
request,
|
||||||
};
|
};
|
||||||
standardMetadataValidateBucketAndObj(metadataValParams, request.actionImplicitDenies, log, next);
|
standardMetadataValidateBucketAndObj(metadataValParams, request.actionImplicitDenies, log, next);
|
||||||
|
@ -143,13 +131,6 @@ function completeMultipartUpload(authInfo, request, log, callback) {
|
||||||
oldByteLength = objMD['content-length'];
|
oldByteLength = objMD['content-length'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPutVersion) {
|
|
||||||
const error = validatePutVersionId(objMD, putVersionId, log);
|
|
||||||
if (error) {
|
|
||||||
return next(error, destBucket);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return services.metadataValidateMultipart(metadataValParams,
|
return services.metadataValidateMultipart(metadataValParams,
|
||||||
(err, mpuBucket, mpuOverview, storedMetadata) => {
|
(err, mpuBucket, mpuOverview, storedMetadata) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -416,8 +397,9 @@ function completeMultipartUpload(authInfo, request, log, callback) {
|
||||||
extraPartLocations, pseudoCipherBundle,
|
extraPartLocations, pseudoCipherBundle,
|
||||||
completeObjData, options, droppedMPUSize, next) {
|
completeObjData, options, droppedMPUSize, next) {
|
||||||
const dataToDelete = options.dataToDelete;
|
const dataToDelete = options.dataToDelete;
|
||||||
|
// take versionId from where initiateMultipartUpload saves it originally
|
||||||
/* eslint-disable no-param-reassign */
|
/* eslint-disable no-param-reassign */
|
||||||
metaStoreParams.versionId = options.versionId;
|
metaStoreParams.versionId = storedMetadata.versionId;
|
||||||
metaStoreParams.versioning = options.versioning;
|
metaStoreParams.versioning = options.versioning;
|
||||||
metaStoreParams.isNull = options.isNull;
|
metaStoreParams.isNull = options.isNull;
|
||||||
metaStoreParams.deleteNullKey = options.deleteNullKey;
|
metaStoreParams.deleteNullKey = options.deleteNullKey;
|
||||||
|
|
|
@ -22,6 +22,7 @@ const { validateHeaders, compareObjectLockInformation } =
|
||||||
require('./apiUtils/object/objectLockHelpers');
|
require('./apiUtils/object/objectLockHelpers');
|
||||||
const { getObjectSSEConfiguration } = require('./apiUtils/bucket/bucketEncryption');
|
const { getObjectSSEConfiguration } = require('./apiUtils/bucket/bucketEncryption');
|
||||||
const { setExpirationHeaders } = require('./apiUtils/object/expirationHeaders');
|
const { setExpirationHeaders } = require('./apiUtils/object/expirationHeaders');
|
||||||
|
const { generateVersionId } = require('./apiUtils/object/versioning');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sample xml response:
|
Sample xml response:
|
||||||
|
@ -163,6 +164,11 @@ function initiateMultipartUpload(authInfo, request, log, callback) {
|
||||||
if (MPUbucket.getMdBucketModelVersion() < 2) {
|
if (MPUbucket.getMdBucketModelVersion() < 2) {
|
||||||
metadataStoreParams.splitter = constants.oldSplitter;
|
metadataStoreParams.splitter = constants.oldSplitter;
|
||||||
}
|
}
|
||||||
|
// Generate version id before creating multipart upload so uploadPart
|
||||||
|
// can store data with a reference to the correct object version
|
||||||
|
const vcfg = destinationBucket.getVersioningConfiguration();
|
||||||
|
const isVersionedObj = vcfg && vcfg.Status === 'Enabled';
|
||||||
|
metadataStoreParams.versionId = isVersionedObj ? generateVersionId() : '';
|
||||||
return services.metadataStoreMPObject(MPUbucket.getName(),
|
return services.metadataStoreMPObject(MPUbucket.getName(),
|
||||||
cipherBundle, metadataStoreParams,
|
cipherBundle, metadataStoreParams,
|
||||||
log, (err, mpuMD) => {
|
log, (err, mpuMD) => {
|
||||||
|
|
|
@ -175,6 +175,7 @@ const services = {
|
||||||
options.versioning = versioning;
|
options.versioning = versioning;
|
||||||
}
|
}
|
||||||
if (versionId || versionId === '') {
|
if (versionId || versionId === '') {
|
||||||
|
// FIXME Move to md.versionId
|
||||||
options.versionId = versionId;
|
options.versionId = versionId;
|
||||||
}
|
}
|
||||||
if (needOplogUpdate) {
|
if (needOplogUpdate) {
|
||||||
|
@ -471,6 +472,7 @@ const services = {
|
||||||
};
|
};
|
||||||
multipartObjectMD.key = params.objectKey;
|
multipartObjectMD.key = params.objectKey;
|
||||||
multipartObjectMD.uploadId = params.uploadId;
|
multipartObjectMD.uploadId = params.uploadId;
|
||||||
|
multipartObjectMD.versionId = params.versionId;
|
||||||
multipartObjectMD['cache-control'] = params.headers['cache-control'];
|
multipartObjectMD['cache-control'] = params.headers['cache-control'];
|
||||||
multipartObjectMD['content-disposition'] =
|
multipartObjectMD['content-disposition'] =
|
||||||
params.headers['content-disposition'];
|
params.headers['content-disposition'];
|
||||||
|
|
Loading…
Reference in New Issue