* 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)
| 192 | * the associated metadata |
| 193 | */ |
| 194 | function 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. |
no test coverage detected