* Check if the object is already restored, and update the expiration date accordingly: * > After restoring an archived object, you can update the restoration period by reissuing the * > request with a new period. Amazon S3 updates the restoration period relative to the current * > time. * * @pa
(objectMD, log)
| 174 | * @return {boolean} - true if the object is already restored |
| 175 | */ |
| 176 | function _updateObjectExpirationDate(objectMD, log) { |
| 177 | // Check if restoreCompletedAt field exists |
| 178 | // Normally, we should check `archive.restoreWillExpireAt > current time`; however this is |
| 179 | // checked earlier in the process, so checking again here would create weird states |
| 180 | const isObjectAlreadyRestored = !!objectMD.archive.restoreCompletedAt; |
| 181 | log.debug('The restore status of the object.', { |
| 182 | isObjectAlreadyRestored, |
| 183 | method: 'isObjectAlreadyRestored' |
| 184 | }); |
| 185 | if (isObjectAlreadyRestored) { |
| 186 | const expiryDate = new Date(objectMD.archive.restoreRequestedAt); |
| 187 | expiryDate.setTime(expiryDate.getTime() + (objectMD.archive.restoreRequestedDays * scaledMsPerDay)); |
| 188 | |
| 189 | /* eslint-disable no-param-reassign */ |
| 190 | objectMD.archive.restoreWillExpireAt = expiryDate; |
| 191 | objectMD['x-amz-restore'] = { |
| 192 | 'ongoing-request': false, |
| 193 | 'expiry-date': expiryDate, |
| 194 | 'content-md5': objectMD['x-amz-restore']?.['content-md5'], |
| 195 | }; |
| 196 | /* eslint-enable no-param-reassign */ |
| 197 | } |
| 198 | return isObjectAlreadyRestored; |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * update restore expiration date. |