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

Function getFileToBuild

lib/routes/veeam/utils.js:194–217  ·  view source on GitHub ↗

* Helper to extract the file from the bucket metadata * * @param {object} request - incoming request * @param {object} data - the bucket metadata or input data * @param {boolean} inlineLastModified - true if LastModified should be in the returned object * or as another standalone field * @retu

(request, data, inlineLastModified = false)

Source from the content-addressed store, hash-verified

192 * the associated metadata
193 */
194function getFileToBuild(request, data, inlineLastModified = false) {
195 const _isSystemXML = isSystemXML(request.objectKey);
196 const fileToBuild = _isSystemXML ? data?.SystemInfo : data?.CapacityInfo;
197
198 if (!fileToBuild) {
199 return { error: errors.NoSuchKey };
200 }
201
202 const modified = fileToBuild.LastModified || (new Date()).toISOString();
203 const fieldName = _isSystemXML ? 'SystemInfo' : 'CapacityInfo';
204
205 if (inlineLastModified) {
206 fileToBuild.LastModified = modified;
207 } else {
208 delete fileToBuild.LastModified;
209 }
210
211 return {
212 value: {
213 [fieldName]: fileToBuild,
214 },
215 fieldName,
216 };
217}
218
219/**
220 * Fetches capacity metrics from UtilizationService for a bucket.

Callers 2

putVeeamFileFunction · 0.85
buildVeeamFileDataFunction · 0.85

Calls 1

isSystemXMLFunction · 0.85

Tested by

no test coverage detected