Fix r85635. Move LocalFile::publish() magic to LocalFile::publishTo() which has an...
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Fri, 17 Jun 2011 17:12:20 +0000 (17:12 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Fri, 17 Jun 2011 17:12:20 +0000 (17:12 +0000)
includes/filerepo/LocalFile.php
includes/filerepo/OldLocalFile.php

index dd0e315..0e3bc65 100644 (file)
@@ -1043,20 +1043,30 @@ class LocalFile extends File {
         * @param $srcPath String: local filesystem path to the source image
         * @param $flags Integer: a bitwise combination of:
         *     File::DELETE_SOURCE      Delete the source file, i.e. move rather than copy
-        * @param $dstArchiveName string File name if the file is to be published 
-        *     into the archive
         * @return FileRepoStatus object. On success, the value member contains the
         *     archive name, or an empty string if it was a new file.
         */
-       function publish( $srcPath, $flags = 0, $dstArchiveName = null ) {
-               $this->lock();
+       function publish( $srcPath, $flags = 0 ) {
+               return $this->publishTo( $srcPath, $this->getRel(), $flags );
+       }
 
-               if ( $dstArchiveName ) {
-                       $dstRel = 'archive/' . $this->getHashPath() . $dstArchiveName;
-               } else {
-                       $dstRel = $this->getRel();
-               }
-                       
+       /**
+        * Move or copy a file to a specified location. Returns a FileRepoStatus 
+        * object with the archive name in the "value" member on success.
+        *
+        * The archive name should be passed through to recordUpload for database
+        * registration.
+        *
+        * @param $srcPath String: local filesystem path to the source image
+        * @param $dstRel String: target relative path
+        * @param $flags Integer: a bitwise combination of:
+        *     File::DELETE_SOURCE      Delete the source file, i.e. move rather than copy
+        * @return FileRepoStatus object. On success, the value member contains the
+        *     archive name, or an empty string if it was a new file.
+        */
+       function publishTo( $srcPath, $dstRel, $flags = 0 ) {
+               $this->lock();
+               
                $archiveName = wfTimestamp( TS_MW ) . '!'. $this->getName();
                $archiveRel = 'archive/' . $this->getHashPath() . $archiveName;
                $flags = $flags & File::DELETE_SOURCE ? LocalRepo::DELETE_SOURCE : 0;
index ba07e4f..1fb8c56 100644 (file)
@@ -223,9 +223,11 @@ class OldLocalFile extends LocalFile {
         */
        function uploadOld( $srcPath, $archiveName, $timestamp, $comment, $user, $flags = 0 ) {
                $this->lock();
-               $status = $this->publish( $srcPath, 
-                       $flags & File::DELETE_SOURCE ? FileRepo::DELETE_SOURCE : 0, 
-                       $archiveName );
+               
+               $dstRel = 'archive/' . $this->getHashPath() . $archiveName;
+               $status = $this->publishTo( $srcPath, $dstRel,
+                       $flags & File::DELETE_SOURCE ? FileRepo::DELETE_SOURCE : 0
+               );
                
                if ( $status->isGood() ) {
                        if ( !$this->recordOldUpload( $srcPath, $archiveName, $timestamp, $comment, $user ) ) {