[Django] #30422: Temp upload file does not get deleted on canceled upload request

35 views
Skip to first unread message

Django

unread,
Apr 28, 2019, 7:27:30 AM4/28/19
to django-...@googlegroups.com
#30422: Temp upload file does not get deleted on canceled upload request
------------------------------------------------+------------------------
Reporter: drutalj | Owner: nobody
Type: Bug | Status: new
Component: File uploads/storage | 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 |
------------------------------------------------+------------------------
Temporary file does not get deleted when upload (request) is canceled by
client (e.g. browser is closed before upload is finished).

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

Django

unread,
Apr 29, 2019, 6:53:40 AM4/29/19
to django-...@googlegroups.com
#30422: Temporary files do not get deleted on canceled upload request.
--------------------------------------+------------------------------------

Reporter: drutalj | Owner: nobody
Type: Bug | Status: new
Component: File uploads/storage | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by felixxm):

* version: 2.2 => master
* stage: Unreviewed => Accepted


Old description:

> Temporary file does not get deleted when upload (request) is canceled by
> client (e.g. browser is closed before upload is finished).

New description:

Temporary files do not get deleted when upload (request) is canceled by


client (e.g. browser is closed before upload is finished).

--

Comment:

Reproduced at ed880d92b50c641c3e7f6e8ce5741085ffe1f8fb with
`django.core.files.uploadhandler.TemporaryFileUploadHandler`.

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

Django

unread,
May 14, 2019, 11:16:50 AM5/14/19
to django-...@googlegroups.com
#30422: Temporary files do not get deleted on canceled upload request.
-------------------------------------+-------------------------------------
Reporter: drutalj | Owner: Mattia
| Procopio
Type: Bug | Status: assigned
Component: File | Version: master
uploads/storage |

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mattia Procopio):

* owner: nobody => Mattia Procopio
* status: new => assigned


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

Django

unread,
May 15, 2019, 6:04:45 AM5/15/19
to django-...@googlegroups.com
#30422: Temporary files do not get deleted on canceled upload request.
-------------------------------------+-------------------------------------
Reporter: drutalj | Owner: Mattia
| Procopio
Type: Bug | Status: assigned
Component: File | Version: master
uploads/storage |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mattia Procopio):

I am analysing a bit the code to deal with uploads. I have noticed that
`file_complete` method is never called if upload is interrupted.
Now, since content lenght seems to be unreliable (in my tests is always 0)
I am thinking how to solve this issue in a clean way.
One of the option I am thinking about is to add a new flag to
TemporaryFileUploadHandler that will be set to `True` within
`file_complete` and having some cleanup code within `upload_complete` that
will check if the flag is `True` or `False` and will delete the incomplete
file.
Does this sound right?

--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:3>

Django

unread,
Feb 12, 2020, 12:00:28 PM2/12/20
to django-...@googlegroups.com
#30422: Temporary files do not get deleted on canceled upload request.
-------------------------------------+-------------------------------------
Reporter: drutalj | Owner: Mattia
| Procopio
Type: Bug | Status: assigned
Component: File | Version: master
uploads/storage |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Sanskar Jaiswal):

Does this have a PR merged? If not can I look into this? I want to get
started with contributing to Django for a while now, but I haven't been
able to do so. Also, could someone please tell me if this ticket is easy
enough for a beginner to resolve?

--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:4>

Django

unread,
Feb 12, 2020, 12:22:26 PM2/12/20
to django-...@googlegroups.com
#30422: Temporary files do not get deleted on canceled upload request.
-------------------------------------+-------------------------------------
Reporter: drutalj | Owner: Mattia
| Procopio
Type: Bug | Status: assigned
Component: File | Version: master
uploads/storage |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson):

Hi Sanskar. There's no patch. You can look into Mattia's suggestion to see
if it makes sense.

--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:5>

Django

unread,
Feb 17, 2020, 6:00:32 AM2/17/20
to django-...@googlegroups.com
#30422: Temporary files do not get deleted on canceled upload request.
--------------------------------------+------------------------------------
Reporter: drutalj | Owner: (none)
Type: Bug | Status: new
Component: File uploads/storage | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Mattia Procopio):

* owner: Mattia Procopio => (none)
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:6>

Django

unread,
Feb 19, 2020, 1:22:25 PM2/19/20
to django-...@googlegroups.com
#30422: Temporary files do not get deleted on canceled upload request.
-------------------------------------+-------------------------------------
Reporter: drutalj | Owner: Sanskar
| Jaiswal

Type: Bug | Status: assigned
Component: File | Version: master
uploads/storage |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sanskar Jaiswal):

* owner: (none) => Sanskar Jaiswal


* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:7>

Django

unread,
Feb 20, 2020, 5:46:05 AM2/20/20
to django-...@googlegroups.com
#30422: Temporary files do not get deleted on canceled upload request.
-------------------------------------+-------------------------------------
Reporter: drutalj | Owner: Sanskar
| Jaiswal
Type: Bug | Status: assigned
Component: File | Version: master
uploads/storage |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/12475 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:8>

Django

unread,
Aug 6, 2020, 10:24:55 AM8/6/20
to django-...@googlegroups.com
#30422: Temporary files do not get deleted on canceled upload request.
-------------------------------------+-------------------------------------
Reporter: drutalj | Owner: Sanskar
| Jaiswal
Type: Bug | Status: assigned
Component: File | Version: master
uploads/storage |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Sanskar Jaiswal):

All tests run on my machine (macOS) but the CI test on Windows fails
because of a PermissionError, due to the temporary file being used by some
other process. Is there any possible fix for this on Windows? Or should I
just alter my patch to handle such os errors and label this patch as POSIX
only?

--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:9>

Django

unread,
Sep 1, 2020, 5:07:25 AM9/1/20
to django-...@googlegroups.com
#30422: Temporary files do not get deleted on canceled upload request.
-------------------------------------+-------------------------------------
Reporter: drutalj | Owner: Sanskar
| Jaiswal
Type: Bug | Status: assigned
Component: File | Version: master
uploads/storage |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sanskar Jaiswal):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:10>

Django

unread,
Sep 1, 2020, 6:51:28 AM9/1/20
to django-...@googlegroups.com
#30422: Temporary files do not get deleted on canceled upload request.
-------------------------------------+-------------------------------------
Reporter: drutalj | Owner: Sanskar
| Jaiswal
Type: Bug | Status: assigned
Component: File | Version: master
uploads/storage |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:11>

Django

unread,
Sep 15, 2020, 7:20:24 AM9/15/20
to django-...@googlegroups.com
#30422: Temporary files do not get deleted on canceled upload request.
-------------------------------------+-------------------------------------
Reporter: drutalj | Owner: Sanskar
| Jaiswal
Type: Bug | Status: assigned
Component: File | Version: master
uploads/storage |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sanskar Jaiswal):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:12>

Django

unread,
Sep 15, 2020, 7:52:50 AM9/15/20
to django-...@googlegroups.com
#30422: Temporary files do not get deleted on canceled upload request.
-------------------------------------+-------------------------------------
Reporter: drutalj | Owner: Sanskar
| Jaiswal
Type: Bug | Status: assigned
Component: File | Version: master
uploads/storage |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 0 => 1

* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:13>

Django

unread,
Sep 28, 2020, 5:51:07 AM9/28/20
to django-...@googlegroups.com
#30422: Temporary files do not get deleted on canceled upload request.
-------------------------------------+-------------------------------------
Reporter: drutalj | Owner: Sanskar
| Jaiswal
Type: Bug | Status: assigned
Component: File | Version: master
uploads/storage |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:15>

Django

unread,
Sep 30, 2020, 4:55:50 AM9/30/20
to django-...@googlegroups.com
#30422: Temporary files do not get deleted on canceled upload request.
-------------------------------------+-------------------------------------
Reporter: drutalj | Owner: Sanskar
| Jaiswal
Type: Bug | Status: closed

Component: File | Version: master
uploads/storage |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"11c4a4412b74bb1dfe52d706a58f230066821c33" 11c4a44]:
{{{
#!CommitTicketReference repository=""
revision="11c4a4412b74bb1dfe52d706a58f230066821c33"
Fixed #30422 -- Made TemporaryFileUploadHandler handle interrupted
uploads.

This patch allows upload handlers to handle interrupted uploads.

Co-Authored-By: Mariusz Felisiak <felisiak...@gmail.com>
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:17>

Reply all
Reply to author
Forward
0 new messages