diff --git a/storages/backends/s3boto3.py b/storages/backends/s3boto3.py index 4e9aa9d97..0d0cb3924 100644 --- a/storages/backends/s3boto3.py +++ b/storages/backends/s3boto3.py @@ -469,13 +469,11 @@ def exists(self, name): self.connection.meta.client.head_object(Bucket=self.bucket_name, Key=name) return True except ClientError as error: - if error.response.get('Error', {}).get('Code') == '404': + if error.response['ResponseMetadata']['HTTPStatusCode'] == 404: return False - # Some other error was encountered. As `get_available_name` calls this, - # we have to assume the filename is unavailable. If we return true due to some - # other error, we'd overwrite a file. - return True + # Some other error was encountered. Re-raise it. + raise def listdir(self, name): path = self._normalize_name(self._clean_name(name))