Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/improvement/CLDSRV-512-use-TPF-v…
Browse files Browse the repository at this point in the history
…ariable-when-restore-adjust' into w/8.8/improvement/CLDSRV-512-use-TPF-variable-when-restore-adjust
  • Loading branch information
KillianG committed Feb 27, 2024
2 parents c6ba7f9 + a009527 commit 39cba3e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/api/apiUtils/object/coldStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const errors = require('arsenal').errors;
const { config } = require('../../../Config');
const { locationConstraints } = config;

const { scaledMsPerDay } = config.getTimeOptions();

/**
* Get response header "x-amz-restore"
* Be called by objectHead.js
Expand Down Expand Up @@ -145,7 +147,7 @@ function _updateObjectExpirationDate(objectMD, log) {
});
if (isObjectAlreadyRestored) {
const expiryDate = new Date(objectMD.archive.restoreRequestedAt);
expiryDate.setDate(expiryDate.getDate() + objectMD.archive.restoreRequestedDays);
expiryDate.setTime(expiryDate.getTime() + (objectMD.archive.restoreRequestedDays * scaledMsPerDay));

/* eslint-disable no-param-reassign */
objectMD.archive.restoreWillExpireAt = expiryDate;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenko/cloudserver",
"version": "8.8.19",
"version": "8.8.20",
"description": "Zenko CloudServer, an open-source Node.js implementation of a server handling the Amazon S3 protocol",
"main": "index.js",
"engines": {
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/api/apiUtils/coldStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const {
} = require('../../../../lib/api/apiUtils/object/coldStorage');
const { DummyRequestLogger } = require('../../helpers');
const { ObjectMD, ObjectMDArchive } = require('arsenal/build/lib/models');
const { config } = require('../../../../lib/Config');
const { scaledMsPerDay } = config.getTimeOptions();
const log = new DummyRequestLogger();
const oneDay = 24 * 60 * 60 * 1000;

Expand Down Expand Up @@ -227,8 +229,7 @@ describe('cold storage', () => {

assert.strictEqual(objectMd.archive.restoreCompletedAt, restoreCompletedAt);
assert.strictEqual(objectMd.archive.restoreWillExpireAt.getTime(),
objectMd.archive.restoreRequestedAt.getTime() + 5 * oneDay
);
objectMd.archive.restoreRequestedAt.getTime() + (5 * scaledMsPerDay));
assert.deepEqual(objectMd['x-amz-restore'], {
'ongoing-request': false,
'expiry-date': objectMd.archive.restoreWillExpireAt,
Expand Down

0 comments on commit 39cba3e

Please sign in to comment.