Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dvasilas committed Jun 30, 2023
1 parent 71831d3 commit 5243cf9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
4 changes: 4 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ if [[ "$BUCKETD_BOOTSTRAP" ]]; then
JQ_FILTERS_CONFIG="$JQ_FILTERS_CONFIG | .bucketd.bootstrap=[\"$BUCKETD_BOOTSTRAP\""]
fi

if [[ "$TESTING_MODE" ]]; then
JQ_FILTERS_CONFIG="$JQ_FILTERS_CONFIG | .testingMode=true"
fi

if [[ $JQ_FILTERS_CONFIG != "." ]]; then
jq "$JQ_FILTERS_CONFIG" config.json > config.json.tmp
mv config.json.tmp config.json
Expand Down
3 changes: 1 addition & 2 deletions lib/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -1300,8 +1300,7 @@ class Config extends EventEmitter {

this.lifecycleRoleName = config.lifecycleRoleName || null;

this.hookLastModified = config.hookLastModified || false;
this.hookLastModified = true;
this.testingMode = config.testingMode || false;
}

_configureBackends() {
Expand Down
20 changes: 20 additions & 0 deletions lib/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,25 @@ const { setObjectLockInformation }
= require('./api/apiUtils/object/objectLockHelpers');
const removeAWSChunked = require('./api/apiUtils/object/removeAWSChunked');
const { parseTagFromQuery } = s3middleware.tagging;
const { config } = require('./Config');

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();
Expand Down Expand Up @@ -101,6 +116,11 @@ const services = {
log.trace('storing object in metadata');
assert.strictEqual(typeof bucketName, 'string');
const md = new ObjectMD();

if (config.testingMode) {
_maybeSetLastModifiedFromHeader(md, metaHeaders);
}

// This should be object creator's canonical ID.
md.setOwnerId(authInfo.getCanonicalID())
.setCacheControl(cacheControl)
Expand Down

0 comments on commit 5243cf9

Please sign in to comment.