MCPcopy
hub / github.com/scality/cloudserver / metadataGetObject

Function metadataGetObject

lib/metadata/metadataUtils.js:137–158  ·  view source on GitHub ↗

metadataGetObject - retrieves specified object or version from metadata * @param {string} bucketName - name of bucket * @param {string} objectKey - name of object key * @param {string} [versionId] - version of object to retrieve * @param {object} cachedDocuments - cached version of the documents

(bucketName, objectKey, versionId, cachedDocuments, log, cb)

Source from the content-addressed store, hash-verified

135 * @return {undefined} - and call callback with err, bucket md and object md
136 */
137function metadataGetObject(bucketName, objectKey, versionId, cachedDocuments, log, cb) {
138 // versionId may be 'null', which asks metadata to fetch the null key specifically
139 const options = { versionId, getDeleteMarker: true };
140 if (cachedDocuments && cachedDocuments[objectKey]) {
141 return cb(null, cachedDocuments[objectKey]);
142 }
143 return metadata.getObjectMD(bucketName, objectKey, options, log,
144 (err, objMD) => {
145 if (err) {
146 if (err.is && err.is.NoSuchKey && versionId === 'null') {
147 return getNullVersionFromMaster(bucketName, objectKey, log, cb);
148 }
149 if (err.is && err.is.NoSuchKey) {
150 log.debug('object does not exist in metadata');
151 return cb();
152 }
153 log.debug('err getting object MD from metadata', { error: err });
154 return cb(err);
155 }
156 return cb(null, objMD);
157 });
158}
159
160/** metadataGetObjects - retrieves specified object or version from metadata. This
161 * method uses cursors, hence is only compatible with a MongoDB DB backend.

Callers 4

putObjectTaggingFunction · 0.85
deleteObjectTaggingFunction · 0.85
changeObjectLockFunction · 0.85

Calls 2

getNullVersionFromMasterFunction · 0.85
debugMethod · 0.80

Tested by

no test coverage detected