From 2b98965a2d36c1b437662ef3bef90d8f399978c2 Mon Sep 17 00:00:00 2001 From: Dimitrios Vasilas Date: Fri, 30 Jun 2023 15:39:46 +0200 Subject: [PATCH] wip --- constants.js | 1 + lib/services.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/constants.js b/constants.js index 7946248058..525f537b8b 100644 --- a/constants.js +++ b/constants.js @@ -110,6 +110,7 @@ const constants = { // user metadata header to set object locationConstraint objectLocationConstraintHeader: 'x-amz-meta-scal-location-constraint', + forcedLastModifiedTsHeader: 'x-amz-meta-x-scal-last-modified', legacyLocations: ['sproxyd', 'legacy'], /* eslint-disable camelcase */ externalBackends: { aws_s3: true, azure: true, gcp: true }, diff --git a/lib/services.js b/lib/services.js index 2fa7517b64..a0b071d694 100644 --- a/lib/services.js +++ b/lib/services.js @@ -18,6 +18,20 @@ const { parseTagFromQuery } = s3middleware.tagging; const usersBucket = constants.usersBucket; const oldUsersBucket = constants.oldUsersBucket; +function _maybeSetLastModifiedFromHeader(md, metaHeaders) { + const forcedLastModifiedTsHeader = constants.forcedLastModifiedTsHeader; + + if (metaHeaders[forcedLastModifiedTsHeader]) { + const forcedLastModifiedTs = Date.parse(metaHeaders[forcedLastModifiedTsHeader]); + const forcedLastModified = new Date(forcedLastModifiedTs).toJSON(); + + // eslint-disable-next-line no-param-reassign + md._data['last-modified'] = forcedLastModified; + // eslint-disable-next-line no-param-reassign + delete metaHeaders[forcedLastModifiedTsHeader]; + } +} + const services = { getService(authInfo, request, log, splitter, cb, overrideUserbucket) { const canonicalID = authInfo.getCanonicalID(); @@ -101,6 +115,9 @@ const services = { log.trace('storing object in metadata'); assert.strictEqual(typeof bucketName, 'string'); const md = new ObjectMD(); + + _maybeSetLastModifiedFromHeader(md, metaHeaders); + // This should be object creator's canonical ID. md.setOwnerId(authInfo.getCanonicalID()) .setCacheControl(cacheControl)