jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[bugfix]: Upload: Only set filekey/offset for files with names

When copy-uploading, the filekey and offset should not be set, as
this applies only when there is a filename, but during a copy-upload,
there is only a URL.

Bug: T294916
Change-Id: I38d0915ca46f2e144522e4c63961b3dc09a1943f
---
M pywikibot/site/_apisite.py
1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index 4d11d71..8a7854f 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -2863,26 +2863,35 @@

if result['result'] == 'Warning':
assert 'warnings' in result and not ignore_all_warnings
- if 'filekey' in result:
- _file_key = result['filekey']
- elif 'sessionkey' in result:
- # TODO: Probably needs to be reflected in the API call
- # above
- _file_key = result['sessionkey']
- pywikibot.warning('Using sessionkey instead of filekey.')
+
+ if source_filename:
+ if 'filekey' in result:
+ _file_key = result['filekey']
+ elif 'sessionkey' in result:
+ # TODO: Probably needs to be reflected in the API call
+ # above
+ _file_key = result['sessionkey']
+ pywikibot.warning(
+ 'Using sessionkey instead of filekey.')
+ else:
+ _file_key = None
+ pywikibot.warning('No filekey defined.')
else:
_file_key = None
- pywikibot.warning('No filekey defined.')

if not report_success:
- result.setdefault('offset', True)
+ if source_filename:
+ offset = result.setdefault('offset', True)
+ else:
+ offset = False
+
if ignore_warnings(create_warnings_list(result)):
return self.upload(
filepage, source_filename=source_filename,
source_url=source_url, comment=comment,
text=text, watch=watch, ignore_warnings=True,
chunk_size=chunk_size, asynchronous=asynchronous,
- _file_key=_file_key, _offset=result['offset'],
+ _file_key=_file_key, _offset=offset,
report_success=False)
return False


To view, visit change 736464. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I38d0915ca46f2e144522e4c63961b3dc09a1943f
Gerrit-Change-Number: 736464
Gerrit-PatchSet: 3
Gerrit-Owner: Inductiveload <inductiveload@gmail.com>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki@aol.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged