Skip to content

Commit 8dba75f

Browse files
committed
Improve quota logic to dedup code and use waterfall properly
Issue: CLDSRV-669
1 parent 1f4d7d3 commit 8dba75f

File tree

1 file changed

+18
-29
lines changed

1 file changed

+18
-29
lines changed

lib/api/completeMultipartUpload.js

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -569,39 +569,28 @@ function completeMultipartUpload(authInfo, request, log, callback) {
569569
extraPartLocationsCount: extraPartLocations.length,
570570
error: err,
571571
});
572-
573-
// Continue with quota validation but don't fail if it errors either
574-
return validateQuotas(request, destinationBucket, request.accountQuotas,
575-
['objectDelete'], 'objectDelete', -droppedMPUSize, false, log, quotaErr => {
576-
if (quotaErr) {
577-
log.warn('failed to update inflights after extra part deletion failure', {
578-
method: 'completeMultipartUpload',
579-
error: quotaErr,
580-
});
581-
}
582-
// Always succeed - the core operation was successful
583-
return next(null, destinationBucket, aggregateETag, generatedVersionId);
584-
});
585572
}
586-
587-
return validateQuotas(request, destinationBucket, request.accountQuotas,
588-
['objectDelete'], 'objectDelete', -droppedMPUSize, false, log, err => {
589-
if (err) {
590-
// Ignore error, as the data has been deleted already: only inflight count
591-
// has not been updated, and will be eventually consistent anyway
592-
log.warn('failed to update inflights', {
593-
method: 'completeMultipartUpload',
594-
extraPartLocations,
595-
error: err,
596-
});
597-
}
598-
return next(null, destinationBucket, aggregateETag,
599-
generatedVersionId);
600-
});
573+
return next(null, destinationBucket, aggregateETag,
574+
generatedVersionId, droppedMPUSize);
601575
});
602576
}
603577
return next(null, destinationBucket, aggregateETag,
604-
generatedVersionId);
578+
generatedVersionId, droppedMPUSize);
579+
},
580+
function updateQuotas(destinationBucket, aggregateETag, generatedVersionId, droppedMPUSize, next) {
581+
return validateQuotas(request, destinationBucket, request.accountQuotas,
582+
['objectDelete'], 'objectDelete', -droppedMPUSize, false, log, err => {
583+
if (err) {
584+
// Ignore error, as the data has been deleted already: only inflight count
585+
// has not been updated, and will be eventually consistent anyway
586+
log.warn('failed to update inflights', {
587+
method: 'completeMultipartUpload',
588+
error: err,
589+
});
590+
}
591+
return next(null, destinationBucket, aggregateETag,
592+
generatedVersionId);
593+
});
605594
},
606595
], (err, destinationBucket, aggregateETag, generatedVersionId) => {
607596
const corsHeaders =

0 commit comments

Comments
 (0)