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

Function deleteObject

lib/services.js:350–395  ·  view source on GitHub ↗

* Deletes objects from a bucket * @param {string} bucketName - bucket in which objectMD is stored * @param {object} objectMD - object's metadata * @param {string} objectKey - object key name * @param {object} options - other instructions, such as { versionId } to *

(bucketName, objectMD, objectKey, options, deferLocationDeletion, log, originOp, cb)

Source from the content-addressed store, hash-verified

348 * @return {undefined}
349 */
350 deleteObject(bucketName, objectMD, objectKey, options, deferLocationDeletion, log, originOp, cb) {
351 log.trace('deleting object from bucket');
352 assert.strictEqual(typeof bucketName, 'string');
353 assert.strictEqual(typeof objectMD, 'object');
354
355 function deleteMDandData() {
356 return metadata.deleteObjectMD(bucketName, objectKey, options, log,
357 (err, res) => {
358 if (err) {
359 return cb(err, res);
360 }
361 log.trace('deleteObject: metadata delete OK');
362 if (objectMD.location === null) {
363 return cb(null, res);
364 }
365
366 if (deferLocationDeletion) {
367 return cb(null, Array.isArray(objectMD.location)
368 ? objectMD.location : [objectMD.location]);
369 }
370
371 if (!Array.isArray(objectMD.location)) {
372 data.delete(objectMD.location, log);
373 return cb(null, res);
374 }
375
376 return data.batchDelete(objectMD.location, null, null, log, err => {
377 if (err) {
378 return cb(err);
379 }
380 return cb(null, res);
381 });
382 }, originOp);
383 }
384
385 const objGetInfo = objectMD.location;
386 // special case that prevents azure blocks from unecessary deletion
387 // will return null if no need
388 return data.protectAzureBlocks(bucketName, objectKey, objGetInfo,
389 log, err => {
390 if (err) {
391 return cb(err);
392 }
393 return deleteMDandData();
394 });
395 },
396
397 /**
398 * Gets list of objects in bucket

Callers

nothing calls this directly

Calls 2

deleteMDandDataFunction · 0.85
traceMethod · 0.80

Tested by

no test coverage detected