diff options
Diffstat (limited to 'includes/upload/UploadFromStash.php')
-rw-r--r-- | includes/upload/UploadFromStash.php | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/includes/upload/UploadFromStash.php b/includes/upload/UploadFromStash.php index d79641ce..cb85fc63 100644 --- a/includes/upload/UploadFromStash.php +++ b/includes/upload/UploadFromStash.php @@ -45,16 +45,16 @@ class UploadFromStash extends UploadBase { // user object. sometimes this won't exist, as when running from cron. $this->user = $user; - if( $repo ) { + if ( $repo ) { $this->repo = $repo; } else { $this->repo = RepoGroup::singleton()->getLocalRepo(); } - if( $stash ) { + if ( $stash ) { $this->stash = $stash; } else { - if( $user ) { + if ( $user ) { wfDebug( __METHOD__ . " creating new UploadStash instance for " . $user->getId() . "\n" ); } else { wfDebug( __METHOD__ . " creating new UploadStash instance with no user\n" ); @@ -89,7 +89,7 @@ class UploadFromStash extends UploadBase { * @param $key string * @param $name string */ - public function initialize( $key, $name = 'upload_file' ) { + public function initialize( $key, $name = 'upload_file', $initTempFile = true ) { /** * Confirming a temporarily stashed upload. * We don't want path names to be forged, so we keep @@ -98,7 +98,7 @@ class UploadFromStash extends UploadBase { */ $metadata = $this->stash->getMetadata( $key ); $this->initializePathInfo( $name, - $this->getRealPath ( $metadata['us_path'] ), + $initTempFile ? $this->getRealPath( $metadata['us_path'] ) : false, $metadata['us_size'], false ); @@ -129,6 +129,14 @@ class UploadFromStash extends UploadBase { return $this->mSourceType; } + /** + * Get the base 36 SHA1 of the file + * @return string + */ + public function getTempFileSha1Base36() { + return $this->mFileProps['sha1']; + } + /* * protected function verifyFile() inherited */ @@ -136,12 +144,13 @@ class UploadFromStash extends UploadBase { /** * Stash the file. * + * @param $user User * @return UploadStashFile */ - public function stashFile() { + public function stashFile( User $user = null ) { // replace mLocalFile with an instance of UploadStashFile, which adds some methods // that are useful for stashed files. - $this->mLocalFile = parent::stashFile(); + $this->mLocalFile = parent::stashFile( $user ); return $this->mLocalFile; } |