Skip to content

Commit

Permalink
issue/theriverman#34: Storage.stat() now raises AttributeError when c…
Browse files Browse the repository at this point in the history
…lient.stat_object fails

This resolves compatibility with delete_file() in collectstatic. See more at https://github.com/django/django/blob/2f73e5406d54cb8945e187eff302a3a3373350be/django/contrib/staticfiles/management/commands/collectstatic.py#L252
  • Loading branch information
theriverman committed Dec 12, 2021
1 parent a9fb1b0 commit ddb50ef
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions django_minio_backend/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,8 @@ def stat(self, name: str) -> Union[minio.datatypes.Object, bool]:
try:
obj = self.client.stat_object(self.bucket, object_name=object_name)
return obj
except (minio.error.S3Error, minio.error.ServerError):
return False
except urllib3.exceptions.MaxRetryError:
return False
except (minio.error.S3Error, minio.error.ServerError, urllib3.exceptions.MaxRetryError):
raise AttributeError(f'Could not stat object ({name}) in bucket ({self.bucket})')

def delete(self, name: str):
"""
Expand Down

0 comments on commit ddb50ef

Please sign in to comment.