* start to restore object. * If not exist x-amz-restore, add it to objectMD.(x-amz-restore = false) * calculate restore expiry-date and add it to objectMD. * Be called by objectRestore.js * * @param {ObjectMD} objectMD - objectMd instance * @param {object} restoreParam - bucket name * @param
(objectMD, restoreParam, log, cb)
| 244 | * |
| 245 | */ |
| 246 | function startRestore(objectMD, restoreParam, log, cb) { |
| 247 | log.debug('Validating if restore can be done or not.'); |
| 248 | const checkResultError = _validateStartRestore(objectMD, log); |
| 249 | if (checkResultError) { |
| 250 | log.debug('Restore cannot be done.', { |
| 251 | error: checkResultError, |
| 252 | method: 'startRestore' |
| 253 | }); |
| 254 | return cb(checkResultError); |
| 255 | } |
| 256 | const updateResultError = _updateRestoreInfo(objectMD, restoreParam, log); |
| 257 | if (updateResultError) { |
| 258 | log.debug('Failed to update restore information.', { |
| 259 | error: updateResultError, |
| 260 | method: 'startRestore' |
| 261 | }); |
| 262 | return cb(updateResultError); |
| 263 | } |
| 264 | log.debug('Validated and updated restore information', { |
| 265 | method: 'startRestore' |
| 266 | }); |
| 267 | const isObjectAlreadyRestored = _updateObjectExpirationDate(objectMD, log); |
| 268 | return cb(null, isObjectAlreadyRestored); |
| 269 | } |
| 270 | |
| 271 | /** |
| 272 | * checks if object data is available or if it's in cold storage |
no test coverage detected