|
12 | 12 | import mimetypes |
13 | 13 | import ssl |
14 | 14 | import datetime |
| 15 | +import sys |
15 | 16 | from pathlib import Path |
16 | 17 | from typing import Union, List, Tuple, Optional |
17 | 18 | from concurrent.futures import ThreadPoolExecutor, as_completed |
18 | | -from typing import Union, List |
19 | 19 | import hashlib |
20 | 20 | from datetime import timedelta |
21 | 21 |
|
|
34 | 34 | from django.core.cache import cache |
35 | 35 |
|
36 | 36 |
|
37 | | -from .utils import MinioServerStatus, PrivatePublicMixedError, ConfigurationError, get_setting, get_storages_setting |
| 37 | +from .utils import MinioServerStatus, PrivatePublicMixedError, ConfigurationError, get_setting |
38 | 38 |
|
39 | 39 |
|
40 | 40 | __all__ = ['MinioBackend', 'MinioBackendStatic', 'get_iso_date', 'iso_date_prefix', ] |
@@ -305,7 +305,12 @@ def exists(self, name: str) -> bool: |
305 | 305 | object_name = Path(name).as_posix() |
306 | 306 | try: |
307 | 307 | self.stat(object_name) |
308 | | - except (minio.error.S3Error, minio.error.ServerError, urllib3.exceptions.MaxRetryError, AttributeError, FileNotFoundError) as e: |
| 308 | + except minio.error.S3Error as e: |
| 309 | + if ("collectstatic" in sys.argv) and getattr(e, "code", None) in {"NoSuchKey", "NoSuchObject"}: |
| 310 | + return False |
| 311 | + logger.info(msg=f"Object could not be found: {self.bucket}/{name}", exc_info=e) |
| 312 | + return False |
| 313 | + except (minio.error.ServerError, urllib3.exceptions.MaxRetryError, AttributeError, FileNotFoundError) as e: |
309 | 314 | logger.info(msg=f"Object could not be found: {self.bucket}/{name}", exc_info=e) |
310 | 315 | return False |
311 | 316 | return True |
|
0 commit comments