MCPcopy Index your code
hub / github.com/scality/cloudserver / _prepareNullVersionDeletion

Function _prepareNullVersionDeletion

lib/api/apiUtils/object/versioning.js:123–163  ·  view source on GitHub ↗

check existence and get location of null version data for deletion * @param {string} bucketName - name of bucket * @param {string} objKey - name of object key * @param {object} options - metadata options for getting object MD * @param {string} options.versionId - version to get from metadata * @para

(bucketName, objKey, options, mst, log, cb)

Source from the content-addressed store, hash-verified

121* @return {undefined} - and call callback with (err, dataToDelete)
122*/
123function _prepareNullVersionDeletion(bucketName, objKey, options, mst, log, cb) {
124 const nullOptions = {};
125 if (!options.deleteData) {
126 return process.nextTick(cb, null, nullOptions);
127 }
128 if (options.versionId === mst.versionId) {
129 // no need to get another key as the master is the target
130 nullOptions.dataToDelete = mst.objLocation;
131 return process.nextTick(cb, null, nullOptions);
132 }
133 if (options.versionId === 'null') {
134 // deletion of the null key will be done by the main metadata
135 // PUT via this option
136 nullOptions.deleteNullKey = true;
137 }
138 return metadata.getObjectMD(bucketName, objKey, options, log,
139 (err, versionMD) => {
140 if (err) {
141 // the null key may not exist, hence it's a normal
142 // situation to have a NoSuchKey error, in which case
143 // there is nothing to delete
144 if (err.is.NoSuchKey) {
145 log.debug('null version does not exist', {
146 method: '_prepareNullVersionDeletion',
147 });
148 } else {
149 log.warn('could not get null version metadata', {
150 error: err,
151 method: '_prepareNullVersionDeletion',
152 });
153 }
154 return cb(err);
155 }
156 if (versionMD.location) {
157 const dataToDelete = Array.isArray(versionMD.location) ?
158 versionMD.location : [versionMD.location];
159 nullOptions.dataToDelete = dataToDelete;
160 }
161 return cb(null, nullOptions);
162 });
163}
164
165function _deleteNullVersionMD(bucketName, objKey, options, log, cb) {
166 return metadata.deleteObjectMD(bucketName, objKey, options, log, err => {

Callers 1

versioningPreprocessingFunction · 0.85

Calls 2

debugMethod · 0.80
warnMethod · 0.80

Tested by

no test coverage detected