Skip to content

Commit 5d42ac5

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

7 files changed

Lines changed: 938 additions & 931 deletions

File tree

eslint.config.mjs

Lines changed: 71 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,82 @@
1-
import mocha from "eslint-plugin-mocha";
2-
import promise from "eslint-plugin-promise";
3-
import n from "eslint-plugin-n";
4-
import prettier from "eslint-config-prettier";
5-
import path from "node:path";
6-
import { fileURLToPath } from "node:url";
7-
import js from "@eslint/js";
8-
import { FlatCompat } from "@eslint/eslintrc";
1+
import mocha from 'eslint-plugin-mocha';
2+
import promise from 'eslint-plugin-promise';
3+
import n from 'eslint-plugin-n';
4+
import prettier from 'eslint-config-prettier';
5+
import path from 'node:path';
6+
import { fileURLToPath } from 'node:url';
7+
import js from '@eslint/js';
8+
import { FlatCompat } from '@eslint/eslintrc';
99

1010
const __filename = fileURLToPath(import.meta.url);
1111
const __dirname = path.dirname(__filename);
1212
const compat = new FlatCompat({
1313
baseDirectory: __dirname,
1414
recommendedConfig: js.configs.recommended,
15-
allConfig: js.configs.all
15+
allConfig: js.configs.all,
1616
});
1717

18-
export default [...compat.extends('@scality/scality'), {
19-
plugins: {
20-
mocha,
21-
promise,
22-
n,
23-
},
18+
export default [
19+
...compat.extends('@scality/scality'),
20+
{
21+
plugins: {
22+
mocha,
23+
promise,
24+
n,
25+
},
2426

25-
languageOptions: {
26-
ecmaVersion: 2021,
27-
sourceType: "script",
28-
},
27+
languageOptions: {
28+
ecmaVersion: 2021,
29+
sourceType: 'script',
30+
},
2931

30-
rules: {
31-
"import/extensions": "off",
32-
"lines-around-directive": "off",
33-
"no-underscore-dangle": "off",
34-
"indent": "off",
35-
"object-curly-newline": "off",
36-
"operator-linebreak": "off",
37-
"function-paren-newline": "off",
38-
"import/newline-after-import": "off",
39-
"prefer-destructuring": "off",
40-
"implicit-arrow-linebreak": "off",
41-
"no-bitwise": "off",
42-
"dot-location": "off",
43-
"comma-dangle": "off",
44-
"no-undef-init": "off",
45-
"global-require": "off",
46-
"import/no-dynamic-require": "off",
47-
"class-methods-use-this": "off",
48-
"no-plusplus": "off",
49-
"no-else-return": "off",
50-
"object-property-newline": "off",
51-
"import/order": "off",
52-
"no-continue": "off",
53-
"no-tabs": "off",
54-
"lines-between-class-members": "off",
55-
"prefer-spread": "off",
56-
"no-lonely-if": "off",
57-
"no-useless-escape": "off",
58-
"no-restricted-globals": "off",
59-
"no-buffer-constructor": "off",
60-
"import/no-extraneous-dependencies": "off",
61-
"space-unary-ops": "off",
62-
"no-useless-return": "off",
63-
"no-unexpected-multiline": "off",
64-
"no-mixed-operators": "off",
65-
"newline-per-chained-call": "off",
66-
"operator-assignment": "off",
67-
"spaced-comment": "off",
68-
"comma-style": "off",
69-
"no-restricted-properties": "off",
70-
"new-parens": "off",
71-
"no-multi-spaces": "off",
72-
"quote-props": "off",
73-
"mocha/no-exclusive-tests": "error",
74-
"no-redeclare": ["error", { "builtinGlobals": false }],
75-
"promise/prefer-await-to-then": "warn",
76-
"n/callback-return": "warn",
32+
rules: {
33+
'import/extensions': 'off',
34+
'lines-around-directive': 'off',
35+
'no-underscore-dangle': 'off',
36+
indent: 'off',
37+
'object-curly-newline': 'off',
38+
'operator-linebreak': 'off',
39+
'function-paren-newline': 'off',
40+
'import/newline-after-import': 'off',
41+
'prefer-destructuring': 'off',
42+
'implicit-arrow-linebreak': 'off',
43+
'no-bitwise': 'off',
44+
'dot-location': 'off',
45+
'comma-dangle': 'off',
46+
'no-undef-init': 'off',
47+
'global-require': 'off',
48+
'import/no-dynamic-require': 'off',
49+
'class-methods-use-this': 'off',
50+
'no-plusplus': 'off',
51+
'no-else-return': 'off',
52+
'object-property-newline': 'off',
53+
'import/order': 'off',
54+
'no-continue': 'off',
55+
'no-tabs': 'off',
56+
'lines-between-class-members': 'off',
57+
'prefer-spread': 'off',
58+
'no-lonely-if': 'off',
59+
'no-useless-escape': 'off',
60+
'no-restricted-globals': 'off',
61+
'no-buffer-constructor': 'off',
62+
'import/no-extraneous-dependencies': 'off',
63+
'space-unary-ops': 'off',
64+
'no-useless-return': 'off',
65+
'no-unexpected-multiline': 'off',
66+
'no-mixed-operators': 'off',
67+
'newline-per-chained-call': 'off',
68+
'operator-assignment': 'off',
69+
'spaced-comment': 'off',
70+
'comma-style': 'off',
71+
'no-restricted-properties': 'off',
72+
'new-parens': 'off',
73+
'no-multi-spaces': 'off',
74+
'quote-props': 'off',
75+
'mocha/no-exclusive-tests': 'error',
76+
'no-redeclare': ['error', { builtinGlobals: false }],
77+
'promise/prefer-await-to-then': 'warn',
78+
'n/callback-return': 'warn',
79+
},
7780
},
78-
}, prettier];
81+
prettier,
82+
];

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)