Skip to content

Commit 226368e

Browse files
committed
CLDSRV-905: run prettier over modified files
1 parent 97ba896 commit 226368e

6 files changed

Lines changed: 867 additions & 864 deletions

File tree

lib/api/apiUtils/object/coldStorage.js

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ const { scaledMsPerDay } = config.getTimeOptions();
1717
* @returns {string|undefined} x-amz-restore
1818
*/
1919
function getAmzRestoreResHeader(objMD) {
20-
if (objMD.archive &&
21-
objMD.archive.restoreRequestedAt &&
22-
!objMD.archive.restoreCompletedAt) {
20+
if (objMD.archive && objMD.archive.restoreRequestedAt && !objMD.archive.restoreCompletedAt) {
2321
// Avoid race condition by relying on the `archive` MD of the object
2422
// and return the right header after a RESTORE request.
2523
return `ongoing-request="true"`;
@@ -82,11 +80,10 @@ function _validateStartRestore(objectMD, log) {
8280
if (new Date(objectMD.archive?.restoreWillExpireAt) < new Date(Date.now())) {
8381
// return InvalidObjectState error if the restored object is expired
8482
// but restore info md of this object has not yet been cleared
85-
log.debug('The restored object already expired.',
86-
{
87-
archive: objectMD.archive,
88-
method: '_validateStartRestore',
89-
});
83+
log.debug('The restored object already expired.', {
84+
archive: objectMD.archive,
85+
method: '_validateStartRestore',
86+
});
9087
return errors.InvalidObjectState;
9188
}
9289

@@ -99,21 +96,19 @@ function _validateStartRestore(objectMD, log) {
9996
if (!isLocationCold) {
10097
// return InvalidObjectState error if the object is not in cold storage,
10198
// not in cold storage means either location cold flag not exists or cold flag is explicit false
102-
log.debug('The bucket of the object is not in a cold storage location.',
103-
{
104-
isLocationCold,
105-
method: '_validateStartRestore',
106-
});
99+
log.debug('The bucket of the object is not in a cold storage location.', {
100+
isLocationCold,
101+
method: '_validateStartRestore',
102+
});
107103
return errors.InvalidObjectState;
108104
}
109105
if (objectMD.archive?.restoreRequestedAt) {
110106
// return RestoreAlreadyInProgress error if the object is currently being restored
111107
// check if archive.restoreRequestAt exists and archive.restoreCompletedAt not yet exists
112-
log.debug('The object is currently being restored.',
113-
{
114-
archive: objectMD.archive,
115-
method: '_validateStartRestore',
116-
});
108+
log.debug('The object is currently being restored.', {
109+
archive: objectMD.archive,
110+
method: '_validateStartRestore',
111+
});
117112
return errors.RestoreAlreadyInProgress;
118113
}
119114
return undefined;
@@ -141,21 +136,24 @@ function validatePutVersionId(objMD, versionId, log) {
141136

142137
const isLocationCold = locationConstraints[objMD.dataStoreName]?.isCold;
143138
if (!isLocationCold) {
144-
log.error('The object data is not stored in a cold storage location.',
145-
{
146-
isLocationCold,
147-
dataStoreName: objMD.dataStoreName,
148-
method: 'validatePutVersionId',
149-
});
139+
log.error('The object data is not stored in a cold storage location.', {
140+
isLocationCold,
141+
dataStoreName: objMD.dataStoreName,
142+
method: 'validatePutVersionId',
143+
});
150144
return errors.InvalidObjectState;
151145
}
152146

153147
// make sure object archive restoration is in progress
154148
// NOTE: we do not use putObjectVersion to update the restoration period.
155-
if (!objMD.archive || !objMD.archive.restoreRequestedAt || !objMD.archive.restoreRequestedDays
156-
|| objMD.archive.restoreCompletedAt || objMD.archive.restoreWillExpireAt) {
157-
log.error('object archive restoration is not in progress',
158-
{ method: 'validatePutVersionId', versionId });
149+
if (
150+
!objMD.archive ||
151+
!objMD.archive.restoreRequestedAt ||
152+
!objMD.archive.restoreRequestedDays ||
153+
objMD.archive.restoreCompletedAt ||
154+
objMD.archive.restoreWillExpireAt
155+
) {
156+
log.error('object archive restoration is not in progress', { method: 'validatePutVersionId', versionId });
159157
return errors.InvalidObjectState;
160158
}
161159

@@ -179,11 +177,11 @@ function _updateObjectExpirationDate(objectMD, log) {
179177
const isObjectAlreadyRestored = !!objectMD.archive.restoreCompletedAt;
180178
log.debug('The restore status of the object.', {
181179
isObjectAlreadyRestored,
182-
method: 'isObjectAlreadyRestored'
180+
method: 'isObjectAlreadyRestored',
183181
});
184182
if (isObjectAlreadyRestored) {
185183
const expiryDate = new Date(objectMD.archive.restoreRequestedAt);
186-
expiryDate.setTime(expiryDate.getTime() + (objectMD.archive.restoreRequestedDays * scaledMsPerDay));
184+
expiryDate.setTime(expiryDate.getTime() + objectMD.archive.restoreRequestedDays * scaledMsPerDay);
187185

188186
/* eslint-disable no-param-reassign */
189187
objectMD.archive.restoreWillExpireAt = expiryDate;
@@ -208,9 +206,9 @@ function _updateObjectExpirationDate(objectMD, log) {
208206
*/
209207
function _updateRestoreInfo(objectMD, restoreParam, log) {
210208
if (!objectMD.archive) {
211-
log.debug('objectMD.archive doesn\'t exits', {
209+
log.debug("objectMD.archive doesn't exits", {
212210
objectMD,
213-
method: '_updateRestoreInfo'
211+
method: '_updateRestoreInfo',
214212
});
215213
return errorInstances.InternalError.customizeDescription('Archive metadata is missing.');
216214
}
@@ -222,7 +220,7 @@ function _updateRestoreInfo(objectMD, restoreParam, log) {
222220
if (!ObjectMDArchive.isValid(objectMD.archive)) {
223221
log.debug('archive is not valid', {
224222
archive: objectMD.archive,
225-
method: '_updateRestoreInfo'
223+
method: '_updateRestoreInfo',
226224
});
227225
return errorInstances.InternalError.customizeDescription('Invalid archive metadata.');
228226
}
@@ -248,20 +246,20 @@ function startRestore(objectMD, restoreParam, log, cb) {
248246
if (checkResultError) {
249247
log.debug('Restore cannot be done.', {
250248
error: checkResultError,
251-
method: 'startRestore'
249+
method: 'startRestore',
252250
});
253251
return cb(checkResultError);
254252
}
255253
const updateResultError = _updateRestoreInfo(objectMD, restoreParam, log);
256254
if (updateResultError) {
257255
log.debug('Failed to update restore information.', {
258256
error: updateResultError,
259-
method: 'startRestore'
257+
method: 'startRestore',
260258
});
261259
return cb(updateResultError);
262260
}
263261
log.debug('Validated and updated restore information', {
264-
method: 'startRestore'
262+
method: 'startRestore',
265263
});
266264
const isObjectAlreadyRestored = _updateObjectExpirationDate(objectMD, log);
267265
return cb(null, isObjectAlreadyRestored);
@@ -274,13 +272,16 @@ function startRestore(objectMD, restoreParam, log, cb) {
274272
*/
275273
function verifyColdObjectAvailable(objMD) {
276274
// return error when object is cold
277-
if (objMD.archive &&
275+
if (
276+
objMD.archive &&
278277
// Object is in cold backend
279278
(!objMD.archive.restoreRequestedAt ||
280279
// Object is being restored
281-
(objMD.archive.restoreRequestedAt && !objMD.archive.restoreCompletedAt))) {
282-
const err = errorInstances.InvalidObjectState
283-
.customizeDescription('The operation is not valid for the object\'s storage class');
280+
(objMD.archive.restoreRequestedAt && !objMD.archive.restoreCompletedAt))
281+
) {
282+
const err = errorInstances.InvalidObjectState.customizeDescription(
283+
"The operation is not valid for the object's storage class",
284+
);
284285
return err;
285286
}
286287
return null;

0 commit comments

Comments
 (0)