#26562: Introduce Storage and FileSystemStorage alternate save behaviour
-------------------------------------+-------------------------------------
Reporter: freshquiz | Owner: nobody
Type: New feature | Status: new
Component: File | Version: master
uploads/storage | Keywords: file FileField storage
Severity: Normal | overwrite filepath
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
I have read through many discussions about justifying why uploaded files
should not be deleted or overwritten, but I don't agree with them at all
(I can get into that if needed) and I think the current implementation of
`django.core.files.storage.Storage.get_available_name()` and
`django.core.files.storage.FileSystemStorage._save()` are quite
undesirable.
The behaviour I am referring to is the fact that the
`Storage.get_available_name()` method is so crucial to the whole storage
and `FileField` game and yet its implementation is susceptible to race
conditions and that it is the root cause of a dev not being granted total
control of the '''final''' file/storage path when saving a file using the
storage API.
Flow on from that, the fact that the `FileSystemStorage._save()` method
infinitely loops until a file path collision does not occur (to open a
file) and then uses low-level locking mechanisms to try and retain
ownership of the file for writing.
If the core devs are keen on retaining this behaviour, so be it.
However, can we please build upon Django's reputation of configurability
and allow for an alternative (and non-default, to appease backwards
compatibility) behaviour where `Storage.get_available_name()` effectively
does nothing (except maybe length truncation) and
`FileSystemStorage._save()` does not have the infinite loop and does not
have the low-level file lock.
My proposals for configurability are:
* Global setting in the settings file
* Static attribute of the `Storage` class, which can be overridden
--
Ticket URL: <https://code.djangoproject.com/ticket/26562>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.0aa2b123f0ceeb25ca1f9b1f1626f777%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.