MCPcopy
hub / github.com/scality/cloudserver / putMetadata

Function putMetadata

lib/routes/routeBackbeat.js:521–876  ·  view source on GitHub ↗
(request, response, bucketInfo, objMd, log, callback)

Source from the content-addressed store, hash-verified

519}
520
521function putMetadata(request, response, bucketInfo, objMd, log, callback) {
522 return _getRequestPayload(request, (err, payload) => {
523 if (err) {
524 return callback(err);
525 }
526
527 let omVal;
528
529 try {
530 omVal = JSON.parse(payload);
531 } catch {
532 return callback(errors.MalformedPOSTRequest);
533 }
534
535 const { headers, bucketName, objectKey } = request;
536
537 // Destination-side delete-marker replication.
538 // We need the REPLICA status to distinguish from
539 // source-side replication status updates that also carry isDeleteMarker=true.
540 if (
541 omVal.isDeleteMarker &&
542 omVal.replicationInfo &&
543 omVal.replicationInfo.status === 'REPLICA' &&
544 request.serverAccessLog
545 ) {
546 // eslint-disable-next-line no-param-reassign
547 request.serverAccessLog.replication = true;
548 // eslint-disable-next-line no-param-reassign
549 request.serverAccessLog.deleteMarker = true;
550 }
551
552 // Destination-side tag-only replication.
553 // AWS uses REST.PUT.OBJECT_TAGGING for both - a tag-delete
554 // is replicated as a PUT of an empty tag set with the same
555 // URI shape.
556 // The REPLICA status excludes source-side replication-status updates.
557 if (
558 omVal.replicationInfo &&
559 omVal.replicationInfo.status === 'REPLICA' &&
560 (omVal.originOp === 's3:ObjectTagging:Put' || omVal.originOp === 's3:ObjectTagging:Delete') &&
561 request.serverAccessLog
562 ) {
563 // eslint-disable-next-line no-param-reassign
564 request.serverAccessLog.replication = true;
565 // eslint-disable-next-line no-param-reassign
566 request.serverAccessLog.tagging = true;
567 }
568
569 // Destination-side ACL-only replication.
570 // AWS uses REST.PUT.ACL on the destination with URI
571 // PUT /<bucket>/<key>?acl&versionId=<srcVersionId> and
572 // populates the aclRequired field.
573 // The REPLICA status excludes source-side replication-status updates.
574 if (
575 omVal.replicationInfo &&
576 omVal.replicationInfo.status === 'REPLICA' &&
577 omVal.originOp === 's3:ObjectAcl:Put' &&
578 request.serverAccessLog

Callers

nothing calls this directly

Calls 11

_getRequestPayloadFunction · 0.85
pushReplicationMetricFunction · 0.85
locationKeysHaveChangedFunction · 0.85
_respondFunction · 0.85
debugMethod · 0.80
traceMethod · 0.80
warnMethod · 0.80
errorMethod · 0.80
infoMethod · 0.80
decodeVersionIdFunction · 0.50

Tested by

no test coverage detected