MCPcopy Index your code
hub / github.com/scality/cloudserver / versioningPreprocessing

Function versioningPreprocessing

lib/api/apiUtils/object/versioning.js:335–389  ·  view source on GitHub ↗

versioningPreprocessing - return versioning information for S3 to handle * creation of new versions and manage deletion of old data and metadata * @param {string} bucketName - name of bucket * @param {object} bucketMD - bucket metadata * @param {string} objectKey - name of object * @param {obje

(bucketName, bucketMD, objectKey, objMD,
    log, callback)

Source from the content-addressed store, hash-verified

333 * options.isNull - (true/undefined) whether new version is null or not
334 */
335function versioningPreprocessing(bucketName, bucketMD, objectKey, objMD,
336 log, callback) {
337 const mst = getMasterState(objMD);
338 const vCfg = bucketMD.getVersioningConfiguration();
339
340 if (!vCfg) {
341 const options = { dataToDelete: mst.objLocation };
342 return process.nextTick(callback, null, options);
343 }
344
345 const { options, nullVersionId, delOptions } =
346 processVersioningState(mst, vCfg.Status, config.nullVersionCompatMode);
347
348 return async.series([
349 function storeNullVersionMD(next) {
350 if (!nullVersionId) {
351 return process.nextTick(next);
352 }
353
354 options.nullVersionId = nullVersionId;
355 return _storeNullVersionMD(bucketName, objectKey, nullVersionId, objMD, log, next);
356 },
357 function prepareNullVersionDeletion(next) {
358 if (!delOptions) {
359 return process.nextTick(next);
360 }
361 return _prepareNullVersionDeletion(
362 bucketName, objectKey, delOptions, mst, log,
363 (err, nullOptions) => {
364 if (err) {
365 return next(err);
366 }
367 Object.assign(options, nullOptions);
368 return next();
369 });
370 },
371 function deleteNullVersionMD(next) {
372 if (delOptions &&
373 delOptions.versionId &&
374 delOptions.versionId !== 'null') {
375 // backward-compat: delete old null versioned key
376 return _deleteNullVersionMD(
377 bucketName, objectKey, { versionId: delOptions.versionId, overheadField }, log, next);
378 }
379 return process.nextTick(next);
380 },
381 ], err => {
382 // it's possible there was a prior request that deleted the
383 // null version, so proceed with putting a new version
384 if (err && err.is.NoSuchKey) {
385 return callback(null, options);
386 }
387 return callback(err, options);
388 });
389}
390
391/** Return options to pass to Metadata layer for version-specific
392 * operations with the given requested version ID

Callers 3

objectCopyFunction · 0.85
completeMultipartUploadFunction · 0.85
createAndStoreObjectFunction · 0.85

Calls 5

getMasterStateFunction · 0.85
processVersioningStateFunction · 0.85
_storeNullVersionMDFunction · 0.85
_deleteNullVersionMDFunction · 0.85

Tested by

no test coverage detected