Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
Merge 63c3c38 into e092439
Browse files Browse the repository at this point in the history
  • Loading branch information
antonagestam committed Aug 12, 2019
2 parents e092439 + 63c3c38 commit 7dc3145
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions collectfast/boto.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
from typing import Any

from django.core.exceptions import ImproperlyConfigured

from . import settings

has_boto = True # type: bool
has_boto3 = True # type: bool

try:
from storages.backends.s3boto import S3BotoStorage
except ImportError:
except (ImportError, ImproperlyConfigured):
has_boto = False

try:
from storages.backends.s3boto3 import S3Boto3Storage
except ImportError:
except (ImportError, ImproperlyConfigured):
has_boto3 = False


Expand All @@ -23,9 +25,12 @@ def is_boto3(storage):

def is_boto(storage):
# type: (Any) -> bool
return has_boto and (
isinstance(storage, S3BotoStorage) or isinstance(storage, S3Boto3Storage)
)
return has_boto and isinstance(storage, S3BotoStorage)


def is_any_boto(storage):
# type: (Any) -> bool
return is_boto(storage) or is_boto3(storage)


def reset_connection(storage):
Expand Down
4 changes: 2 additions & 2 deletions collectfast/management/commands/collectstatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.utils.encoding import smart_str

from collectfast import settings
from collectfast.boto import is_boto
from collectfast.boto import is_any_boto
from collectfast.boto import reset_connection
from collectfast.etag import should_copy_file

Expand Down Expand Up @@ -41,7 +41,7 @@ def __init__(self, *args, **kwargs):
self.tasks = [] # type: List[Task]
self.collectfast_enabled = settings.enabled

if is_boto(self.storage) and self.storage.preload_metadata is not True:
if is_any_boto(self.storage) and self.storage.preload_metadata is not True:
self.storage.preload_metadata = True
warnings.warn(
"Collectfast does not work properly without `preload_metadata` "
Expand Down

0 comments on commit 7dc3145

Please sign in to comment.