Check for warnings for assembled file after a chunked upload
authorBartosz Dziewoński <matma.rex@gmail.com>
Wed, 17 Aug 2016 15:57:47 +0000 (17:57 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Fri, 19 Aug 2016 01:33:10 +0000 (01:33 +0000)
Bug: T130564
Change-Id: Iebc84f030c45c634dc29b02cbd720f33abf50f2b

includes/api/ApiUpload.php
includes/jobqueue/jobs/AssembleUploadChunksJob.php

index 227278c..ac817ba 100644 (file)
@@ -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 );
 
index f3fcadf..060cabb 100644 (file)
@@ -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 ) {