diff options
| author | aryan <aryan@Aryans-MacBook-Pro.local> | 2020-02-20 00:23:48 +0530 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-09-30 10:30:43 +0200 |
| commit | 11c4a4412b74bb1dfe52d706a58f230066821c33 (patch) | |
| tree | e97fad6c1f924d372f791e6637a435f439a1f146 /django/http/multipartparser.py | |
| parent | 21b127bfbc8738705ecee97407161caae612d6b1 (diff) | |
Fixed #30422 -- Made TemporaryFileUploadHandler handle interrupted uploads.
This patch allows upload handlers to handle interrupted uploads.
Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Diffstat (limited to 'django/http/multipartparser.py')
| -rw-r--r-- | django/http/multipartparser.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/django/http/multipartparser.py b/django/http/multipartparser.py index b3472f7be2..8078393a66 100644 --- a/django/http/multipartparser.py +++ b/django/http/multipartparser.py @@ -150,6 +150,8 @@ class MultiPartParser: num_post_keys = 0 # To limit the amount of data read from the request. read_size = None + # Whether a file upload is finished. + uploaded_file = True try: for item_type, meta_data, field_stream in Parser(stream, self._boundary): @@ -159,6 +161,7 @@ class MultiPartParser: # we hit the next boundary/part of the multipart content. self.handle_file_complete(old_field_name, counters) old_field_name = None + uploaded_file = True try: disposition = meta_data['content-disposition'][1] @@ -225,6 +228,7 @@ class MultiPartParser: content_length = None counters = [0] * len(handlers) + uploaded_file = False try: for handler in handlers: try: @@ -279,6 +283,9 @@ class MultiPartParser: if not e.connection_reset: exhaust(self._input_data) else: + if not uploaded_file: + for handler in handlers: + handler.upload_interrupted() # Make sure that the request data is all fed exhaust(self._input_data) |
