Compare commits

...

1 Commits

Author SHA1 Message Date
Nicolas Humbert 32a782618e CLDSRV-481 Check that putMetadata handles null version properly 2023-12-27 20:56:37 +01:00
1 changed files with 11 additions and 2 deletions

View File

@ -477,10 +477,13 @@ function putMetadata(request, response, bucketInfo, objMd, log, callback) {
let versioning = bucketInfo.isVersioningEnabled(); let versioning = bucketInfo.isVersioningEnabled();
let isNull = false; let isNull = false;
console.log('>>>>> INITAL versionId!!!', versionId);
if (versionId === 'null') { if (versionId === 'null') {
isNull = true; isNull = true;
// Retrieve the null version id from the object metadata. // Retrieve the null version id from the object metadata.
versionId = objMd && objMd.versionId; versionId = objMd && objMd.versionId;
console.log('OBJ VERSION ID', versionId);
if (!versionId) { if (!versionId) {
// Set isNull in the object metadata to be written. // Set isNull in the object metadata to be written.
// Since metadata will generate a versionId for the null version, // Since metadata will generate a versionId for the null version,
@ -497,6 +500,7 @@ function putMetadata(request, response, bucketInfo, objMd, log, callback) {
// and then convert bucket to versioned. // and then convert bucket to versioned.
// If no new versioned objects are added for given object(s), they look like // If no new versioned objects are added for given object(s), they look like
// standalone master keys. // standalone master keys.
console.log('HERE!!!');
versioning = false; versioning = false;
} else { } else {
const versioningConf = bucketInfo.getVersioningConfiguration(); const versioningConf = bucketInfo.getVersioningConfiguration();
@ -521,21 +525,26 @@ function putMetadata(request, response, bucketInfo, objMd, log, callback) {
} }
const options = { const options = {
versionId, // versionId,
isNull, isNull,
}; };
// NOTE: When 'versioning' is set to true and no 'versionId' is specified, // NOTE: When 'versioning' is set to true and no 'versionId' is specified,
// it results in the creation of a "new" version, which also updates the master. // it results in the creation of a "new" version, which also updates the master.
// NOTE: Since option fields are converted to strings when they're sent to Metadata via the query string, // NOTE: Since option fields are converted to strings when they're sent to Metadata via the query string,
// Metadata interprets the value "false" as if it were true. // Metadata interprets the value "false" as if it were true or undefined as it were an empty string.
// Therefore, to avoid this confusion, we don't pass the versioning parameter at all if its value is false. // Therefore, to avoid this confusion, we don't pass the versioning parameter at all if its value is false.
if (versioning) { if (versioning) {
options.versioning = true; options.versioning = true;
} }
if (versionId || versionId === '') {
options.versionId = versionId;
}
log.trace('putting object version', { log.trace('putting object version', {
objectKey: request.objectKey, omVal, options }); objectKey: request.objectKey, omVal, options });
console.log('PUT METADATA OPTIONS <<<<<<', options);
return metadata.putObjectMD(bucketName, objectKey, omVal, options, log, return metadata.putObjectMD(bucketName, objectKey, omVal, options, log,
(err, md) => { (err, md) => {
if (err) { if (err) {