From 5b40bb3ae4ed0e4ec6a8430fe38c8f17e9f51473 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Sat, 7 Dec 2024 22:24:30 +0100 Subject: [PATCH] Fix inflight handling for multiObjectDelete Issue: CLDSRV-590 --- lib/api/multiObjectDelete.js | 10 ++++++---- tests/unit/api/multiObjectDelete.js | 6 +++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/api/multiObjectDelete.js b/lib/api/multiObjectDelete.js index 049eba7ed3..36620d7f2f 100644 --- a/lib/api/multiObjectDelete.js +++ b/lib/api/multiObjectDelete.js @@ -31,7 +31,7 @@ const { overheadField } = require('../../constants'); const versionIdUtils = versioning.VersionID; const { data } = require('../data/wrapper'); const logger = require('../utilities/logger'); -const { validateQuotas } = require('./apiUtils/quotas/quotaUtils'); +const { processBytesToWrite, validateQuotas } = require('./apiUtils/quotas/quotaUtils'); /* Format of xml request: @@ -333,9 +333,11 @@ function getObjMetadataAndDelete(authInfo, canonicalID, request, return callback(null, objMD, versionId); }, - (objMD, versionId, callback) => validateQuotas( - request, bucket, request.accountQuotas, ['objectDelete'], 'objectDelete', - -objMD?.['content-length'] || 0, false, log, err => callback(err, objMD, versionId)), + (objMD, versionId, callback) => { + const bytes = processBytesToWrite('objectDelete', bucket, versionId, 0, objMD); + return validateQuotas(request, bucket, request.accountQuotas, ['objectDelete'], + 'objectDelete', bytes, false, log, err => callback(err, objMD, versionId)); + }, (objMD, versionId, callback) => { const options = preprocessingVersioningDelete( bucketName, bucket, objMD, versionId, config.nullVersionCompatMode); diff --git a/tests/unit/api/multiObjectDelete.js b/tests/unit/api/multiObjectDelete.js index 8d4566e22f..bb339cc968 100644 --- a/tests/unit/api/multiObjectDelete.js +++ b/tests/unit/api/multiObjectDelete.js @@ -42,7 +42,11 @@ describe('getObjMetadataAndDelete function for multiObjectDelete', () => { headers: {}, parsedContentLength: contentLength, }, postBody); - const bucket = { getVersioningConfiguration: () => null, getQuota: () => 0 }; + const bucket = { + isVersioningEnabled: () => false, + getVersioningConfiguration: () => null, + getQuota: () => 0, + }; beforeEach(done => { cleanup();