Updated cache to not use get_storage_class

This commit is contained in:
Tris Forster 2024-08-26 11:55:38 +10:00
parent f134df3384
commit 9903bb0088
2 changed files with 5 additions and 4 deletions

View File

@ -1,2 +1,2 @@
__version__ = '0.2.3'
__version__ = '0.2.4'
default_app_config = 'byostorage.apps.BYOStorageConfig'

View File

@ -1,5 +1,6 @@
from django.core.files.storage import Storage, get_storage_class
from django.core.files.storage import Storage, DefaultStorage
from django.utils.deconstruct import deconstructible
from django.utils.module_loading import import_string
from django.conf import settings
from hashlib import sha1
import os.path
@ -15,14 +16,14 @@ class CachedStorage(Storage):
def __init__(self, remote=None, cachedir=None, expires=600):
if not remote:
remote = getattr(settings, 'CACHED_STORAGE_REMOTE', None)
remote = getattr(settings, 'CACHED_STORAGE_REMOTE', DefaultStorage)
if not cachedir:
cachedir = getattr(settings, 'CACHED_STORAGE_DIR', 'cache')
if isinstance(remote, Storage):
self.remote = remote
else:
self.remote = get_storage_class(remote)()
self.remote = import_string(remote)()
self.cachedir = cachedir
self.expires = expires