Skip to content

Commit fb85c7f

Browse files
committed
♻️ remove useless argument to follow caller
Issue: CLDSRV-878
1 parent 6f9012b commit fb85c7f

5 files changed

Lines changed: 21 additions & 26 deletions

File tree

lib/routes/veeam/get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async function getVeeamFile(request, response, bucketMd, log) {
2222
}
2323

2424
try {
25-
const result = await buildVeeamFileData(request, bucketMd, log, 'getVeeamFile');
25+
const result = await buildVeeamFileData(request, bucketMd, log);
2626
return await respondWithData(request, response, log, result.bucketData, result.xmlContent, result.modified);
2727
} catch (err) {
2828
return responseXMLBody(err, null, response, log);

lib/routes/veeam/head.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async function headVeeamFile(request, response, bucketMd, log) {
1717
}
1818

1919
try {
20-
const result = await buildVeeamFileData(request, bucketMd, log, 'headVeeamFile');
20+
const result = await buildVeeamFileData(request, bucketMd, log);
2121
return responseContentHeaders(
2222
null,
2323
{},

lib/routes/veeam/list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async function listVeeamFiles(request, response, bucketMd, log) {
106106
let bucketMetrics;
107107
if (data._capabilities?.VeeamSOSApi?.CapacityInfo) {
108108
try {
109-
bucketMetrics = await fetchCapacityMetrics(bucketMd, request, log, 'listVeeamFiles');
109+
bucketMetrics = await fetchCapacityMetrics(bucketMd, request, log);
110110
} catch {
111111
return responseXMLBody(errors.InternalError, null, response, log);
112112
}

lib/routes/veeam/utils.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,22 +216,20 @@ function getFileToBuild(request, data, inlineLastModified = false) {
216216
* @returns {Promise<object>} bucketMetrics always has at least a `date` field;
217217
* on a real 404 the date defaults to new Date()
218218
*/
219-
async function fetchCapacityMetrics(bucketMd, request, log, method) {
219+
async function fetchCapacityMetrics(bucketMd, request, log) {
220220
const bucketKey = `${bucketMd._name}_${new Date(bucketMd._creationDate).getTime()}`;
221221
try {
222222
return await getUtilizationMetrics('bucket', bucketKey, null, {});
223223
} catch (err) {
224224
const statusCode = err.response?.status || err.statusCode || err.code;
225225
if (statusCode === 404) {
226226
log.warn('UtilizationService returned 404 when fetching capacity metrics', {
227-
method,
228227
bucket: request.bucketName,
229228
error: err.message || err.code,
230229
});
231230
return { date: new Date() };
232231
}
233232
log.error('error fetching capacity metrics from UtilizationService', {
234-
method,
235233
bucket: request.bucketName,
236234
error: err.message || err.code,
237235
statusCode,
@@ -246,10 +244,9 @@ async function fetchCapacityMetrics(bucketMd, request, log, method) {
246244
* @param {object} request - incoming request
247245
* @param {object} bucketMd - bucket metadata from the router
248246
* @param {object} log - logger object
249-
* @param {string} name - calling method name (for log context)
250247
* @returns {Promise<object>} result with { xmlContent, dataBuffer, modified, bucketData }
251248
*/
252-
async function buildVeeamFileData(request, bucketMd, log, name) {
249+
async function buildVeeamFileData(request, bucketMd, log) {
253250
let data;
254251
try {
255252
data = await metadata.getBucketPromised(request.bucketName, log);
@@ -266,7 +263,7 @@ async function buildVeeamFileData(request, bucketMd, log, name) {
266263
let bucketMetrics;
267264
if (!isSystemXML(request.objectKey)) {
268265
try {
269-
bucketMetrics = await fetchCapacityMetrics(bucketMd, request, log, name);
266+
bucketMetrics = await fetchCapacityMetrics(bucketMd, request, log);
270267
} catch {
271268
throw errors.InternalError;
272269
}
@@ -275,11 +272,9 @@ async function buildVeeamFileData(request, bucketMd, log, name) {
275272
}
276273

277274
const modified = bucketMetrics.date;
278-
if (
279-
bucketMetrics.bytesTotal !== undefined
275+
if (bucketMetrics.bytesTotal !== undefined
280276
&& fileToBuild.value.CapacityInfo
281-
&& !fileToBuild.value.CapacityInfo.Used
282-
) {
277+
&& !fileToBuild.value.CapacityInfo.Used) {
283278
fileToBuild.value.CapacityInfo.Used = Number(bucketMetrics.bytesTotal);
284279
fileToBuild.value.CapacityInfo.Available =
285280
Number(fileToBuild.value.CapacityInfo.Capacity) - Number(bucketMetrics.bytesTotal);

tests/unit/routes/veeam-utils.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('fetchCapacityMetrics', () => {
3737
it('should call UtilizationService with the correct bucket key', async () => {
3838
utilizationStub.callsArgWith(4, null, {});
3939

40-
await fetchCapacityMetrics(bucketMd, request, log, 'testMethod');
40+
await fetchCapacityMetrics(bucketMd, request, log);
4141

4242
const expectedKey = `test-bucket_${new Date('2024-01-01T00:00:00.000Z').getTime()}`;
4343
assert.strictEqual(utilizationStub.getCall(0).args[0], 'bucket');
@@ -48,7 +48,7 @@ describe('fetchCapacityMetrics', () => {
4848
const bucketMetrics = { bytesTotal: 42, date: '2026-03-26T19:00:08.996Z' };
4949
utilizationStub.callsArgWith(4, null, bucketMetrics);
5050

51-
const metrics = await fetchCapacityMetrics(bucketMd, request, log, 'testMethod');
51+
const metrics = await fetchCapacityMetrics(bucketMd, request, log);
5252

5353
assert.strictEqual(metrics, bucketMetrics);
5454
assert(!logWarnSpy.called);
@@ -60,7 +60,7 @@ describe('fetchCapacityMetrics', () => {
6060
error404.response = { status: 404 };
6161
utilizationStub.callsArgWith(4, error404);
6262

63-
const metrics = await fetchCapacityMetrics(bucketMd, request, log, 'testMethod');
63+
const metrics = await fetchCapacityMetrics(bucketMd, request, log);
6464

6565
assert(metrics && metrics.date instanceof Date, 'metrics should have a Date for date');
6666
assert(logWarnSpy.calledOnce);
@@ -75,7 +75,7 @@ describe('fetchCapacityMetrics', () => {
7575
error404.statusCode = 404;
7676
utilizationStub.callsArgWith(4, error404);
7777

78-
const metrics = await fetchCapacityMetrics(bucketMd, request, log, 'testMethod');
78+
const metrics = await fetchCapacityMetrics(bucketMd, request, log);
7979

8080
assert(metrics && metrics.date instanceof Date, 'metrics should have a Date for date');
8181
assert(logWarnSpy.calledOnce);
@@ -87,7 +87,7 @@ describe('fetchCapacityMetrics', () => {
8787
utilizationStub.callsArgWith(4, error500);
8888

8989
await assert.rejects(
90-
fetchCapacityMetrics(bucketMd, request, log, 'testMethod'),
90+
fetchCapacityMetrics(bucketMd, request, log),
9191
err => err === error500,
9292
);
9393

@@ -104,7 +104,7 @@ describe('fetchCapacityMetrics', () => {
104104
utilizationStub.callsArgWith(4, connError);
105105

106106
await assert.rejects(
107-
fetchCapacityMetrics(bucketMd, request, log, 'testMethod'),
107+
fetchCapacityMetrics(bucketMd, request, log),
108108
err => err === connError,
109109
);
110110

@@ -174,7 +174,7 @@ describe('buildVeeamFileData', () => {
174174
metadataStub.callsArgWith(2, new Error('DB error'));
175175

176176
await assert.rejects(
177-
buildVeeamFileData(createRequest(capacityObjectKey), bucketMd, log, 'test'),
177+
buildVeeamFileData(createRequest(capacityObjectKey), bucketMd, log),
178178
err => err.code === 500,
179179
);
180180
});
@@ -183,7 +183,7 @@ describe('buildVeeamFileData', () => {
183183
metadataStub.callsArgWith(2, null, { _capabilities: {} });
184184

185185
await assert.rejects(
186-
buildVeeamFileData(createRequest(capacityObjectKey), bucketMd, log, 'test'),
186+
buildVeeamFileData(createRequest(capacityObjectKey), bucketMd, log),
187187
err => err.code === 404,
188188
);
189189
});
@@ -195,7 +195,7 @@ describe('buildVeeamFileData', () => {
195195
utilizationStub.callsArgWith(4, error500);
196196

197197
await assert.rejects(
198-
buildVeeamFileData(createRequest(capacityObjectKey), bucketMd, log, 'test'),
198+
buildVeeamFileData(createRequest(capacityObjectKey), bucketMd, log),
199199
err => err.code === 500,
200200
);
201201
});
@@ -205,7 +205,7 @@ describe('buildVeeamFileData', () => {
205205
metadataStub.callsArgWith(2, null, bucketMd);
206206
utilizationStub.callsArgWith(4, null, { date: metricsDate, bytesTotal: 100 });
207207

208-
const result = await buildVeeamFileData(createRequest(capacityObjectKey), bucketMd, log, 'test');
208+
const result = await buildVeeamFileData(createRequest(capacityObjectKey), bucketMd, log);
209209

210210
assert.strictEqual(result.modified, metricsDate);
211211
assert(result.xmlContent.includes('CapacityInfo'));
@@ -223,7 +223,7 @@ describe('buildVeeamFileData', () => {
223223
error404.response = { status: 404 };
224224
utilizationStub.callsArgWith(4, error404);
225225

226-
const result = await buildVeeamFileData(createRequest(capacityObjectKey), bucketMd, log, 'test');
226+
const result = await buildVeeamFileData(createRequest(capacityObjectKey), bucketMd, log);
227227

228228
assert(result.modified instanceof Date);
229229
assert(result.modified.getTime() >= before);
@@ -234,7 +234,7 @@ describe('buildVeeamFileData', () => {
234234
metadataStub.callsArgWith(2, null, bucketMdWithSystem);
235235
const before = Date.now();
236236

237-
const result = await buildVeeamFileData(createRequest(systemObjectKey), bucketMdWithSystem, log, 'test');
237+
const result = await buildVeeamFileData(createRequest(systemObjectKey), bucketMdWithSystem, log);
238238

239239
assert(!utilizationStub.called, 'should not call UtilizationService for system.xml');
240240
assert(result.modified instanceof Date);
@@ -261,7 +261,7 @@ describe('buildVeeamFileData', () => {
261261
metadataStub.callsArgWith(2, null, bucketMdWithUsed);
262262
utilizationStub.callsArgWith(4, null, { date: new Date(), bytesTotal: 999 });
263263

264-
const result = await buildVeeamFileData(createRequest(capacityObjectKey), bucketMdWithUsed, log, 'test');
264+
const result = await buildVeeamFileData(createRequest(capacityObjectKey), bucketMdWithUsed, log);
265265

266266
assert(result.xmlContent.includes('<Used>400</Used>'), 'should keep existing Used value');
267267
});

0 commit comments

Comments
 (0)