Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_headers caching should be cleaned on delete() #104

Open
cprov opened this issue Sep 7, 2018 · 1 comment
Open

get_headers caching should be cleaned on delete() #104

cprov opened this issue Sep 7, 2018 · 1 comment

Comments

@cprov
Copy link

cprov commented Sep 7, 2018

I understand the caching implemented on get_headers (https://github.com/dennisv/django-storage-swift/blob/master/swift/storage.py#L303) is useful for the reasons described in the code, however it causes a little bit of a pain the following scenario:

When one can't enable AUTO_OVERWRITE, trying to reusing the same filename will always fail, e.g:

if storage.exists(path):
    storage.delete(path)
storage.save(path)

save() calls get_available_name() which, because of the cached results, detects the path still exists and appends the disambiguating suffix. Implicitly adding the suffix is a bad behaviour, but having to clean the cache manually is even worse:

if storage.exists(path):
    storage.delete(path)
    storage.last_headers_name = None
storage.save(path, content)

Could it be done in https://github.com/dennisv/django-storage-swift/blob/master/swift/storage.py#L327 ?

@KostyaEsmukov
Copy link
Contributor

Resetting last_headers_name in delete will definitely help in this particular use-case, but there're others where this cache should be invalidated as well, such as rmtree, _save, and (probably, though I'm not sure) makedirs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants