Another case happens with post-processing since CachedStaticFilesStorage
actually deletes the hash-named file before saving over it.
These issue should be circumventing by directing the writing to a
temporary file name and then atomically renaming it to the intended
destination. Even better, FileSystemStorage._save() has to site in a
While-loop because of race conditions in get_available_name(). Instead,
it could defer calling get_available_name until it's prepared to rename
the file to its destination.
I'm working on implementing these changes in my own sub-class of
FileSystemStorage (and CachedStaticFilesStorage to avoid the delete()
call) and would be apply to submit them as a patch if there's interest.
--
Ticket URL: <https://code.djangoproject.com/ticket/21602>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted
Comment:
Agreed that atomic rename should be used.
--
Ticket URL: <https://code.djangoproject.com/ticket/21602#comment:1>
* type: Uncategorized => Cleanup/optimization
--
Ticket URL: <https://code.djangoproject.com/ticket/21602#comment:2>
Comment (by Tim Graham):
This is also suggested in #27334 (closed as duplicate).
--
Ticket URL: <https://code.djangoproject.com/ticket/21602#comment:3>