From 5deab781bd80c751ce79c2d6c130078061902c7c Mon Sep 17 00:00:00 2001 From: Matthias Mullie Date: Wed, 15 May 2019 09:13:15 +0200 Subject: [PATCH] Don't allow completing a partial stash upload finishUploadToStash could be called on an incomplete upload. E.g. upload 1 chunk (that gets you the filekey) and then call finishUploadToStash's finishUpload. This adds another check for the stash result. The result will only be 'Success' if all chunks have been submitted (or when the file was uploaded as a whole, not chunked) If we're still missing some chunks, result will be 'Continue'. Bug: T190988 Change-Id: Ia0a4df0306b3e0cc0f2453f986b73bedd88241d3 --- resources/src/mediawiki.api/upload.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/src/mediawiki.api/upload.js b/resources/src/mediawiki.api/upload.js index 619dd7c613..fe21f072c6 100644 --- a/resources/src/mediawiki.api/upload.js +++ b/resources/src/mediawiki.api/upload.js @@ -551,8 +551,9 @@ return finishUpload; }, function ( errorCode, result ) { - if ( result && result.upload && result.upload.filekey ) { - // Ignore any warnings if 'filekey' was returned, that's all we care about + if ( result && result.upload && result.upload.result === 'Success' && result.upload.filekey ) { + // Catch handler is also called in case of warnings (e.g. 'duplicate') + // We don't really care about those warnings, as long as the upload got stashed... filekey = result.upload.filekey; return $.Deferred().resolve( finishUpload ); } -- 2.20.1