--
Ticket URL: <https://code.djangoproject.com/ticket/30422>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* 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>
* owner: nobody => Mattia Procopio
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:2>
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>
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>
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>
* owner: Mattia Procopio => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:6>
* owner: (none) => Sanskar Jaiswal
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:7>
* 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>
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>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:10>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:11>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:12>
* needs_better_patch: 0 => 1
* needs_tests: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:13>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/30422#comment:15>
* 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>