Skip to content

Commit

Permalink
[s3] Re-raise non-404 errors in .exists()
Browse files Browse the repository at this point in the history
  • Loading branch information
jschneier committed Oct 26, 2021
1 parent 8942ff2 commit de94608
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions storages/backends/s3boto3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit de94608

Please sign in to comment.