async checkStatus()

in source/checksum/lib/restore/index.js [169:200]


  async checkStatus() {
    const response = await this.instance.headObject({
      Bucket: this.bucket,
      Key: this.key,
    }).promise();

    this.etag = this.etag || response.ETag;

    if (this.etag !== response.ETag) {
      throw new MismatchETagError();
    }

    /* "Restore": "ongoing-request=\"true\"" */
    const status = this.parseKeyValuePair(response.Restore);

    this.storageClass = response.StorageClass;
    this.restoreExpiredAt = (status[KEY_EXPIRY_DATE])
      ? new Date(status[KEY_EXPIRY_DATE]).getTime()
      : undefined;

    if (response.StorageClass !== 'GLACIER' && response.StorageClass !== 'DEEP_ARCHIVE') {
      this.restoreStatus = 'COMPLETED';
    } else if (status[KEY_ONGOING_REQUEST] === 'false') {
      this.restoreStatus = 'COMPLETED';
    } else if (!response.Restore) {
      await this.restore();
      this.restoreStatus = 'IN_PROGRESS';
    } else {
      this.restoreStatus = 'IN_PROGRESS';
    }
    return this.responseData();
  }