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

Function restoreMetadata

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

* Keep metadatas when the object is restored from cold storage * but remove the specific ones we don't want to keep * @param {object} objMD - obj metadata * @param {object} metadataStoreParams - custom built object containing resource details. * @return {undefined}

(objMD, metadataStoreParams)

Source from the content-addressed store, hash-verified

479 * @return {undefined}
480 */
481function restoreMetadata(objMD, metadataStoreParams) {
482 /* eslint-disable no-param-reassign */
483 const userMDToSkip = ['x-amz-meta-scal-s3-restore-attempt'];
484 // We need to keep user metadata and tags
485 Object.keys(objMD).forEach(key => {
486 if (key.startsWith('x-amz-meta-') && !userMDToSkip.includes(key)) {
487 metadataStoreParams.metaHeaders[key] = objMD[key];
488 }
489 });
490
491 if (objMD['x-amz-website-redirect-location']) {
492 if (!metadataStoreParams.headers) {
493 metadataStoreParams.headers = {};
494 }
495 metadataStoreParams.headers['x-amz-website-redirect-location'] = objMD['x-amz-website-redirect-location'];
496 }
497
498 if (objMD.replicationInfo) {
499 metadataStoreParams.replicationInfo = objMD.replicationInfo;
500 }
501
502 if (objMD.legalHold) {
503 metadataStoreParams.legalHold = objMD.legalHold;
504 }
505
506 if (objMD.acl) {
507 metadataStoreParams.acl = objMD.acl;
508 }
509
510 metadataStoreParams.creationTime = objMD['creation-time'];
511 metadataStoreParams.lastModifiedDate = objMD['last-modified'];
512 metadataStoreParams.taggingCopy = objMD.tags;
513}
514
515/** overwritingVersioning - return versioning information for S3 to handle
516 * storing version metadata with a specific version id.

Callers 1

overwritingVersioningFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected