Lokal Profil has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/323396

Change subject: Recover from an allowed warning in the first chunk of an upload
......................................................................

Recover from an allowed warning in the first chunk of an upload

Bug: T151562
Change-Id: If9e946138f50100dfb752f113b87344eea366116
---
M pywikibot/site.py
1 file changed, 12 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/96/323396/1

diff --git a/pywikibot/site.py b/pywikibot/site.py
index f4267ca..d24dcc5 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -5986,7 +5986,6 @@
                     'For the file key "{0}" the offset was set to {1} '
                     'while the file is only {2} bytes large.'.format(
                         _file_key, offset, file_size))
-
         if _verify_stash or offset is True:
             if not _file_key:
                 raise ValueError('Without a file key it cannot request the '
@@ -6091,10 +6090,22 @@
                         _file_key = data['filekey']
                         if 'warnings' in data and not ignore_all_warnings:
                             if callable(ignore_warnings):
+                                restart = False
                                 if 'offset' not in data:
+                                    # This is a result of a warning in the 
first
+                                    # chunk. The chunk is not actually stashed
+                                    # so upload must be restarted if the 
warning
+                                    # is allowed.  T112416 and T112405#1637544
+                                    restart = True
                                     data['offset'] = True
                                 if ignore_warnings(create_warnings_list(data)):
                                     # Future warnings of this run can be 
ignored
+                                    if restart:
+                                        return self.upload(
+                                            filepage, source_filename, 
source_url,
+                                            comment, text, watch, True, 
chunk_size,
+                                            None, 0, report_success=False)
+
                                     ignore_warnings = True
                                     ignore_all_warnings = True
                                     offset = data['offset']

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If9e946138f50100dfb752f113b87344eea366116
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Lokal Profil <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to