This commit is contained in:
parent
0f32f3c50c
commit
d1696a37e5
3 changed files with 41 additions and 1 deletions
|
|
@ -10,6 +10,11 @@ ERROR_WITH_KEY_NAME = """{% extends 'single_error' %}
|
|||
{% block extra %}<KeyName>{{ key_name }}</KeyName>{% endblock %}
|
||||
"""
|
||||
|
||||
ERROR_WITH_ARGUMENT = """{% extends 'single_error' %}
|
||||
{% block extra %}<ArgumentName>{{ name }}</ArgumentName>
|
||||
<ArgumentValue>{{ value }}</ArgumentValue>{% endblock %}
|
||||
"""
|
||||
|
||||
ERROR_WITH_CONDITION_NAME = """{% extends 'single_error' %}
|
||||
{% block extra %}<Condition>{{ condition }}</Condition>{% endblock %}
|
||||
"""
|
||||
|
|
@ -68,6 +73,19 @@ class MissingKey(S3ClientError):
|
|||
)
|
||||
|
||||
|
||||
class MissingVersion(S3ClientError):
|
||||
code = 404
|
||||
|
||||
def __init__(self, version_id, *args, **kwargs):
|
||||
kwargs.setdefault("template", "argument_error")
|
||||
kwargs["name"] = "versionId"
|
||||
kwargs["value"] = version_id
|
||||
self.templates["argument_error"] = ERROR_WITH_ARGUMENT
|
||||
super(MissingVersion, self).__init__(
|
||||
"InvalidArgument", "Invalid version id specified", *args, **kwargs
|
||||
)
|
||||
|
||||
|
||||
class ObjectNotInActiveTierError(S3ClientError):
|
||||
code = 403
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ from .exceptions import (
|
|||
S3ClientError,
|
||||
MissingBucket,
|
||||
MissingKey,
|
||||
MissingVersion,
|
||||
InvalidPartOrder,
|
||||
MalformedXML,
|
||||
MalformedACLError,
|
||||
|
|
@ -1171,8 +1172,10 @@ class ResponseObject(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
|
|||
if_unmodified_since = headers.get("If-Unmodified-Since", None)
|
||||
|
||||
key = self.backend.get_object(bucket_name, key_name, version_id=version_id)
|
||||
if key is None:
|
||||
if key is None and version_id is None:
|
||||
raise MissingKey(key_name)
|
||||
elif key is None:
|
||||
raise MissingVersion(version_id)
|
||||
|
||||
if if_unmodified_since:
|
||||
if_unmodified_since = str_to_rfc_1123_datetime(if_unmodified_since)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue