Skip to content

get_headers caching should be cleaned on delete() #104

@cprov

Description

@cprov

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions