S3: Restored archived objects must be retrievable (#6043)
This commit is contained in:
parent
84174e129d
commit
2c9c7a7a63
@ -1319,7 +1319,10 @@ class S3Response(BaseResponse):
|
|||||||
response_headers["x-amz-version-id"] = key.version_id
|
response_headers["x-amz-version-id"] = key.version_id
|
||||||
|
|
||||||
if key.storage_class in ARCHIVE_STORAGE_CLASSES:
|
if key.storage_class in ARCHIVE_STORAGE_CLASSES:
|
||||||
raise InvalidObjectState(storage_class=key.storage_class)
|
if 'ongoing-request="false"' not in key.response_dict.get(
|
||||||
|
"x-amz-restore", ""
|
||||||
|
):
|
||||||
|
raise InvalidObjectState(storage_class=key.storage_class)
|
||||||
if if_unmodified_since:
|
if if_unmodified_since:
|
||||||
if_unmodified_since = str_to_rfc_1123_datetime(if_unmodified_since)
|
if_unmodified_since = str_to_rfc_1123_datetime(if_unmodified_since)
|
||||||
if key.last_modified.replace(microsecond=0) > if_unmodified_since:
|
if key.last_modified.replace(microsecond=0) > if_unmodified_since:
|
||||||
|
@ -231,8 +231,18 @@ def test_s3_copy_object_for_deep_archive_storage_class_restored():
|
|||||||
Bucket="Bucket", Key="First_Object", Body="Body", StorageClass="DEEP_ARCHIVE"
|
Bucket="Bucket", Key="First_Object", Body="Body", StorageClass="DEEP_ARCHIVE"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
with pytest.raises(ClientError) as exc:
|
||||||
|
s3.get_object(Bucket="Bucket", Key="First_Object")
|
||||||
|
err = exc.value.response["Error"]
|
||||||
|
err["Code"].should.equal("InvalidObjectState")
|
||||||
|
err["Message"].should.equal(
|
||||||
|
"The operation is not valid for the object's storage class"
|
||||||
|
)
|
||||||
|
err["StorageClass"].should.equal("DEEP_ARCHIVE")
|
||||||
|
|
||||||
s3.create_bucket(Bucket="Bucket2")
|
s3.create_bucket(Bucket="Bucket2")
|
||||||
s3.restore_object(Bucket="Bucket", Key="First_Object", RestoreRequest={"Days": 123})
|
s3.restore_object(Bucket="Bucket", Key="First_Object", RestoreRequest={"Days": 123})
|
||||||
|
s3.get_object(Bucket="Bucket", Key="First_Object")
|
||||||
|
|
||||||
s3.copy_object(
|
s3.copy_object(
|
||||||
CopySource={"Bucket": "Bucket", "Key": "First_Object"},
|
CopySource={"Bucket": "Bucket", "Key": "First_Object"},
|
||||||
|
Loading…
Reference in New Issue
Block a user