Skip to content

Commit

Permalink
fix: remove hard-coded overwrite_files in AzureStorage
Browse files Browse the repository at this point in the history
The overwrite_files is True by default, and should be settable from the
django settings using AZURE_OVERWRITE_FILES.

Removing this override will keep the default behaviour (True), while
still allowing users to change it.

NOTE: this change is important because django / django-storages changed
the semantics of the .exists() function, which now returns whether a
path is free for upload (and not whether the file already exists on the
remote storage). With overwrite_files set to True, .exists() will now
always return False.

See jschneier/django-storages#1430
  • Loading branch information
derlin committed Jul 19, 2024
1 parent d8cd6a2 commit 7c2821f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion django_storage_url/backends/az.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import furl
from storages.backends import azure_storage
from django.conf import settings


class AzureStorageFile(azure_storage.AzureStorageFile):
Expand Down Expand Up @@ -56,7 +57,8 @@ def __init__(self, dsn):
self.azure_container = container_name
self.azure_ssl = secure_urls
self.max_memory_size = 10 * 1024**2
self.overwrite_files = True
# The default is False in the superclass
self.overwrite_files = getattr(settings, "AZURE_OVERWRITE_FILES", True)
self.location = ""
self.base_url = str(base_url)

Expand Down

0 comments on commit 7c2821f

Please sign in to comment.