[Django] #31201: Atomic Transaction Roll Back File Upload

63 views
Skip to first unread message

Django

unread,
Jan 23, 2020, 4:22:07 AM1/23/20
to django-...@googlegroups.com
#31201: Atomic Transaction Roll Back File Upload
---------------------------------------------+------------------------
Reporter: Yash Jhunjhunwala | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
For a Model A with FileField

{{{
Model A(models.Model)
file_field = models.FileField()
}}}

Save an instance of model A under a transaction block,
If the transaction fails i.e not committed/rollback , the uploaded file is
not deleted, even though the instance of the model is not saved

--
Ticket URL: <https://code.djangoproject.com/ticket/31201>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 29, 2020, 9:05:21 AM1/29/20
to django-...@googlegroups.com
#31201: Atomic Transaction Roll Back File Upload
-----------------------------------+--------------------------------------

Reporter: Yash Jhunjhunwala | Owner: nobody
Type: Bug | Status: closed
Component: Uncategorized | Version: 2.2
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* resolution: => wontfix


Comment:

This is long-standing behavior, I'm afraid.

[https://docs.djangoproject.com/en/3.0/ref/models/fields/#django.db.models.fields.files.FieldFile.delete
FileField docs]:

> Note that when a model is deleted, related files are not deleted. If you
need to cleanup orphaned files, you’ll need to handle it yourself (for
instance, with a custom management command that can be run manually or
scheduled to run periodically via e.g. cron).

c.f. Malcolm Tredinnick on
https://code.djangoproject.com/ticket/11663#comment:14

Just quickly trying to think about how one might tie the transaction
rollback into the file upload handling, a periodic cleanup command is
instantly more appealing. I hope that makes sense.

--
Ticket URL: <https://code.djangoproject.com/ticket/31201#comment:1>

Django

unread,
Jan 29, 2020, 9:11:09 AM1/29/20
to django-...@googlegroups.com
#31201: Atomic Transaction Roll Back File Upload
-------------------------------------+-------------------------------------

Reporter: Yash Jhunjhunwala | Owner: nobody
Type: Bug | Status: closed
Component: File | Version: 2.2
uploads/storage |
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* component: Uncategorized => File uploads/storage


--
Ticket URL: <https://code.djangoproject.com/ticket/31201#comment:2>

Reply all
Reply to author
Forward
0 new messages