jenkins-bot has submitted this change and it was merged.

Change subject: [FIX] upload: Use correct offset
......................................................................


[FIX] upload: Use correct offset

When a warning occurs and there is no offset in the request it either means
that this is not a chunked upload or that it's the first chunk. If it's not a
chunked upload it should select the offset 'False' and otherwise '0'. The patch
introducing finishing/continuing uploads (d0d1c830) always uses '0' which means
that after a warning with an unchunked upload it'll use a chunked upload (which
does not work for URL uploads).

Using an offset of '0' is in theory wasting the first chunk which may have been
uploaded successfully but unfortunately it might be that not the entire chunk
was transmitted. (There are cases where the returned offset did not match with
the old offset + chunk size)

Change-Id: Ic1e5cb8fee9d4d8ead591947f36c8436540e1b73
---
M pywikibot/site.py
1 file changed, 4 insertions(+), 1 deletion(-)

Approvals:
  John Vandenberg: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/site.py b/pywikibot/site.py
index 130ddb8..76375ae 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -5076,6 +5076,8 @@
                             raise error
                         if 'warnings' in data and not ignore_warnings:
                             result = data
+                            if 'offset' not in result:
+                                result['offset'] = 0
                             break
                         _file_key = data['filekey']
                         throttle = False
@@ -5149,7 +5151,8 @@
             raise pywikibot.UploadWarning(warning, upload_warnings[warning]
                                           % {'msg': message},
                                           file_key=_file_key,
-                                          offset=result['offset'] if 'offset' 
in result else 0)
+                                          offset=result['offset']
+                                                 if 'offset' in result else 
False)
         elif "result" not in result:
             pywikibot.output(u"Upload: unrecognized response: %s" % result)
         if result["result"] == "Success":

-- 
To view, visit https://gerrit.wikimedia.org/r/218010
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic1e5cb8fee9d4d8ead591947f36c8436540e1b73
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <commodorefabia...@gmx.de>
Gerrit-Reviewer: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhall...@arctus.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
Pywikibot-commits mailing list
Pywikibot-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to