Skip to content

Commit

Permalink
Revert "bf(CLDSRV-293): convert multiObjectDelete to use ObjectLockIn…
Browse files Browse the repository at this point in the history
…fo helper"

This reverts commit c7f45df.
  • Loading branch information
alexanderchan-scality committed Nov 29, 2022
1 parent c7f45df commit baf6521
Showing 1 changed file with 5 additions and 43 deletions.
48 changes: 5 additions & 43 deletions lib/api/multiObjectDelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ const { preprocessingVersioningDelete }
const createAndStoreObject = require('./apiUtils/object/createAndStoreObject');
const { metadataGetObject } = require('../metadata/metadataUtils');
const { config } = require('../Config');
const { hasGovernanceBypassHeader, checkUserGovernanceBypass, ObjectLockInfo }
= require('./apiUtils/object/objectLockHelpers');
const { isObjectLocked } = require('./apiUtils/object/objectLockHelpers');
const requestUtils = policies.requestUtils;

const versionIdUtils = versioning.VersionID;
Expand Down Expand Up @@ -230,6 +229,10 @@ function getObjMetadataAndDelete(authInfo, canonicalID, request,
successfullyDeleted.push({ entry });
return callback(skipError);
}
if (versionId && isObjectLocked(bucket, objMD, request.headers)) {
log.debug('trying to delete locked object');
return callback(objectLockedError);
}
if (versionId && objMD.location &&
Array.isArray(objMD.location) && objMD.location[0]) {
// we need this information for data deletes to AWS
Expand All @@ -238,47 +241,6 @@ function getObjMetadataAndDelete(authInfo, canonicalID, request,
}
return callback(null, objMD, versionId);
}),
(objMD, versionId, callback) => {
// AWS only returns an object lock error if a version id
// is specified, else continue to create a delete marker
if (!versionId || !bucket.isObjectLockEnabled()) {
return callback(null, null, objMD, versionId);
}
const hasGovernanceBypass = hasGovernanceBypassHeader(request.headers);
if (hasGovernanceBypass && authInfo.isRequesterAnIAMUser()) {
return checkUserGovernanceBypass(request, authInfo, bucket, entry.key, log, error => {
if (error && error.is.AccessDenied) {
log.debug('user does not have BypassGovernanceRetention and object is locked', { error });
return callback(objectLockedError);
}
if (error) {
return callback(error);
}
return callback(null, hasGovernanceBypass, objMD, versionId);
});
}
return callback(null, hasGovernanceBypass, objMD, versionId);
},
(hasGovernanceBypass, objMD, versionId, callback) => {
// AWS only returns an object lock error if a version id
// is specified, else continue to create a delete marker
if (!versionId || !bucket.isObjectLockEnabled()) {
return callback(null, objMD, versionId);
}
const objLockInfo = new ObjectLockInfo({
mode: objMD.retentionMode,
date: objMD.retentionDate,
legalHold: objMD.legalHold || false,
});

// If the object can not be deleted raise an error
if (!objLockInfo.canModifyObject(hasGovernanceBypass)) {
log.debug('trying to delete locked object');
return callback(objectLockedError);
}

return callback(null, objMD, versionId);
},
(objMD, versionId, callback) =>
preprocessingVersioningDelete(bucketName, bucket, objMD,
versionId, log, (err, options) => callback(err, options,
Expand Down

0 comments on commit baf6521

Please sign in to comment.