Skip to content

Commit

Permalink
[gcloud] remove deprecated GS_CACHE_CONTROL support (#1220)
Browse files Browse the repository at this point in the history
  • Loading branch information
jschneier committed Feb 18, 2023
1 parent c7f2532 commit 306abcb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
django-storages CHANGELOG
=========================

X.YY.Z (UNRELEASED)
*******************

Google Cloud
------------

- **Breaking**: Remove support for deprecated ``GS_CACHE_CONTROL`` (`#1220`_)

.. _#1220: https://github.com/jschneier/django-storages/pull/1196

1.13.2 (2022-12-23)
*******************

Expand Down
11 changes: 0 additions & 11 deletions storages/backends/gcloud.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import gzip
import io
import mimetypes
import warnings
from datetime import timedelta
from tempfile import SpooledTemporaryFile

Expand Down Expand Up @@ -130,7 +129,6 @@ def get_default_settings(self):
'image/svg+xml',
)),
"file_overwrite": setting('GS_FILE_OVERWRITE', True),
"cache_control": setting('GS_CACHE_CONTROL'),
"object_parameters": setting('GS_OBJECT_PARAMETERS', {}),
# The max amount of memory a returned file can take up before being
# rolled over into a temporary file on disk. Default is 0: Do not
Expand Down Expand Up @@ -218,15 +216,6 @@ def get_object_parameters(self, name):
Returns GS_OBJECT_PARAMETRS by default. See the docs for all possible options.
"""
object_parameters = self.object_parameters.copy()

if 'cache_control' not in object_parameters and self.cache_control:
warnings.warn(
'The GS_CACHE_CONTROL setting is deprecated. Use GS_OBJECT_PARAMETERS to set any '
'writable blob property or override GoogleCloudStorage.get_object_parameters to '
'vary the parameters per object.', DeprecationWarning
)
object_parameters['cache_control'] = self.cache_control

return object_parameters

def delete(self, name):
Expand Down
13 changes: 6 additions & 7 deletions tests/test_gcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,14 +406,13 @@ def test_cache_control(self):
data = 'This is some test content.'
filename = 'cache_control_file.txt'
content = ContentFile(data)
cache_control = 'public, max-age=604800'

self.storage.cache_control = cache_control
self.storage.save(filename, content)

bucket = self.storage.client.bucket(self.bucket_name)
blob = bucket.get_blob(filename)
self.assertEqual(blob.cache_control, cache_control)
with override_settings(GS_OBJECT_PARAMETERS={'cache_control': 'public, max-age=604800'}):
self.storage = gcloud.GoogleCloudStorage(bucket_name=self.bucket_name)
self.storage.save(filename, content)
bucket = self.storage.client.bucket(self.bucket_name)
blob = bucket.get_blob(filename)
self.assertEqual(blob.cache_control, 'public, max-age=604800')

def test_storage_save_gzip_twice(self):
"""Test saving the same file content twice with gzip enabled."""
Expand Down

0 comments on commit 306abcb

Please sign in to comment.