Chunked upload: Return expected offset on offset error
authorrillke <rillke@wikipedia.de>
Thu, 12 Feb 2015 15:59:09 +0000 (16:59 +0100)
committerrillke <rillke@wikipedia.de>
Thu, 12 Feb 2015 16:04:41 +0000 (17:04 +0100)
Bug: T87535
Change-Id: If68e0075e73a78c1dd8d95839f7ee9374a995201

includes/api/ApiUpload.php
includes/upload/UploadFromChunks.php

index 62d8882..78a4971 100644 (file)
@@ -218,7 +218,11 @@ class ApiUpload extends ApiBase {
                        $status = $this->mUpload->addChunk(
                                $chunkPath, $chunkSize, $this->mParams['offset'] );
                        if ( !$status->isGood() ) {
-                               $this->dieUsage( $status->getWikiText(), 'stashfailed' );
+                               $extradata = array(
+                                       'offset' => $this->mUpload->getOffset(),
+                               );
+
+                               $this->dieUsage( $status->getWikiText(), 'stashfailed', 0, $extradata );
 
                                return array();
                        }
index 8e6c9c6..3c249ce 100644 (file)
@@ -303,10 +303,10 @@ class UploadFromChunks extends UploadFromFile {
        }
 
        /**
-        * Gets the current offset in fromt the stashedupload table
+        * Get the offset at which the next uploaded chunk will be appended to
         * @return int Current byte offset of the chunk file set
         */
-       private function getOffset() {
+       public function getOffset() {
                if ( $this->mOffset !== null ) {
                        return $this->mOffset;
                }