Fix libcloud url idempotency 133 #1522
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Made
LibCloudStorage.url()
instorages/backends/apache_libcloud.py
idempotent by avoiding unnecessary API calls for non-CDN providers (e.g., Google Cloud Storage) and handling empty paths (e.g.,{% static '' %}
), addressing issue #133. Fixedstorages.utils.clean_name
to preserve empty strings, resolving invalid URLs in Google Cloud Storage (issue #132). Theurl()
method now returns the base bucket URL for empty paths without querying the storage API and skips_get_object
for drivers withoutget_object_cdn_url
. Tests verify behavior across providers, including GCS and S3, and empty path handling. Documentation and changelog updated.Key Changes
Updated
LibCloudStorage.url()
:name
by returning base bucket URL (e.g.,https://storage.googleapis.com/test-bucket/
) without API calls.get_object_cdn_url
before calling_get_object
, avoiding unnecessary API requests for non-CDN drivers.None
for nonexistent objects in CDN mode.Fixed
storages.utils.clean_name
:''
) to prevent transformation to'.'
, fixing 302 redirects in GCS (django-storages generates invalid Google Cloud Storage URL #132).Added tests in
tests/test_apache_libcloud.py
:clean_name('')
returns empty string.