From 959daa2ca44c039e72c8a9a5199d4c74dd05caba Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Wed, 17 Aug 2016 17:57:47 +0200 Subject: [PATCH] Check for warnings for assembled file after a chunked upload Bug: T130564 Change-Id: Iebc84f030c45c634dc29b02cbd720f33abf50f2b --- includes/api/ApiUpload.php | 12 ++++++++++++ includes/jobqueue/jobs/AssembleUploadChunksJob.php | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index 227278c870..ac817ba3c9 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -274,6 +274,12 @@ class ApiUpload extends ApiBase { $this->dieStatusWithCode( $status, 'stashfailed' ); } + // We can only get warnings like 'duplicate' after concatenating the chunks + $warnings = $this->getApiWarnings(); + if ( $warnings ) { + $result['warnings'] = $warnings; + } + // The fully concatenated file has a new filekey. So remove // the old filekey and fetch the new one. UploadBase::setSessionStatus( $this->getUser(), $filekey, false ); @@ -431,6 +437,12 @@ class ApiUpload extends ApiBase { if ( isset( $progress['status']->value['verification'] ) ) { $this->checkVerification( $progress['status']->value['verification'] ); } + if ( isset( $progress['status']->value['warnings'] ) ) { + $warnings = $this->transformWarnings( $progress['status']->value['warnings'] ); + if ( $warnings ) { + $progress['warnings'] = $warnings; + } + } unset( $progress['status'] ); // remove Status object $this->getResult()->addValue( null, $this->getModuleName(), $progress ); diff --git a/includes/jobqueue/jobs/AssembleUploadChunksJob.php b/includes/jobqueue/jobs/AssembleUploadChunksJob.php index f3fcadf623..060cabb627 100644 --- a/includes/jobqueue/jobs/AssembleUploadChunksJob.php +++ b/includes/jobqueue/jobs/AssembleUploadChunksJob.php @@ -73,6 +73,10 @@ class AssembleUploadChunksJob extends Job { return false; } + // We can only get warnings like 'duplicate' after concatenating the chunks + $status = Status::newGood(); + $status->value = [ 'warnings' => $upload->checkWarnings() ]; + // We have a new filekey for the fully concatenated file $newFileKey = $upload->getStashFile()->getFileKey(); @@ -95,7 +99,7 @@ class AssembleUploadChunksJob extends Job { 'stage' => 'assembling', 'filekey' => $newFileKey, 'imageinfo' => $imageInfo, - 'status' => Status::newGood() + 'status' => $status ] ); } catch ( Exception $e ) { -- 2.20.1