Skip to content

Commit

Permalink
Add blob_chunk_size to get_default_settings of GoogleCloudStorage (js…
Browse files Browse the repository at this point in the history
…chneier#878)

Create `blob_chunk_size` as a `GoogleCloudStorage` attribute so that it's easy to override `GS_BLOB_CHUNK_SIZE` in custom Google Cloud storage backends. Without this change, you have to create a new `GoogleCloudFile` and copy a lot of code to make it work
  • Loading branch information
do-rtk authored and mlazowik committed Mar 9, 2022
1 parent 3c037d2 commit 3080a0b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion storages/backends/gcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, name, mode, storage):
if not self.blob and 'w' in mode:
self.blob = Blob(
self.name, storage.bucket,
chunk_size=setting('GS_BLOB_CHUNK_SIZE'))
chunk_size=storage.blob_chunk_size)
if self.blob:
self._apply_backoff_blob()
self._file = None
Expand Down Expand Up @@ -148,6 +148,7 @@ def get_default_settings(self):
# rolled over into a temporary file on disk. Default is 0: Do not
# roll over.
"max_memory_size": setting('GS_MAX_MEMORY_SIZE', 0),
"blob_chunk_size": setting('GS_BLOB_CHUNK_SIZE'),
"retry": setting('GS_RETRY', False),
"initial_delay": setting('GS_INITIAL_DELAY', 1.0),
"max_delay": setting('GS_MAX_DELAY', 60.0),
Expand Down

0 comments on commit 3080a0b

Please sign in to comment.