Index: trunk/phase3/includes/filerepo/OldLocalFile.php |
— | — | @@ -223,10 +223,12 @@ |
224 | 224 | */ |
225 | 225 | function uploadOld( $srcPath, $archiveName, $timestamp, $comment, $user, $flags = 0 ) { |
226 | 226 | $this->lock(); |
227 | | - $status = $this->publish( $srcPath, |
228 | | - $flags & File::DELETE_SOURCE ? FileRepo::DELETE_SOURCE : 0, |
229 | | - $archiveName ); |
230 | 227 | |
| 228 | + $dstRel = 'archive/' . $this->getHashPath() . $archiveName; |
| 229 | + $status = $this->publishTo( $srcPath, $dstRel, |
| 230 | + $flags & File::DELETE_SOURCE ? FileRepo::DELETE_SOURCE : 0 |
| 231 | + ); |
| 232 | + |
231 | 233 | if ( $status->isGood() ) { |
232 | 234 | if ( !$this->recordOldUpload( $srcPath, $archiveName, $timestamp, $comment, $user ) ) { |
233 | 235 | $status->fatal( 'filenotfound', $srcPath ); |
Index: trunk/phase3/includes/filerepo/LocalFile.php |
— | — | @@ -1043,20 +1043,30 @@ |
1044 | 1044 | * @param $srcPath String: local filesystem path to the source image |
1045 | 1045 | * @param $flags Integer: a bitwise combination of: |
1046 | 1046 | * File::DELETE_SOURCE Delete the source file, i.e. move rather than copy |
1047 | | - * @param $dstArchiveName string File name if the file is to be published |
1048 | | - * into the archive |
1049 | 1047 | * @return FileRepoStatus object. On success, the value member contains the |
1050 | 1048 | * archive name, or an empty string if it was a new file. |
1051 | 1049 | */ |
1052 | | - function publish( $srcPath, $flags = 0, $dstArchiveName = null ) { |
| 1050 | + function publish( $srcPath, $flags = 0 ) { |
| 1051 | + return $this->publishTo( $srcPath, $this->getRel(), $flags ); |
| 1052 | + } |
| 1053 | + |
| 1054 | + /** |
| 1055 | + * Move or copy a file to a specified location. Returns a FileRepoStatus |
| 1056 | + * object with the archive name in the "value" member on success. |
| 1057 | + * |
| 1058 | + * The archive name should be passed through to recordUpload for database |
| 1059 | + * registration. |
| 1060 | + * |
| 1061 | + * @param $srcPath String: local filesystem path to the source image |
| 1062 | + * @param $dstRel String: target relative path |
| 1063 | + * @param $flags Integer: a bitwise combination of: |
| 1064 | + * File::DELETE_SOURCE Delete the source file, i.e. move rather than copy |
| 1065 | + * @return FileRepoStatus object. On success, the value member contains the |
| 1066 | + * archive name, or an empty string if it was a new file. |
| 1067 | + */ |
| 1068 | + function publishTo( $srcPath, $dstRel, $flags = 0 ) { |
1053 | 1069 | $this->lock(); |
1054 | | - |
1055 | | - if ( $dstArchiveName ) { |
1056 | | - $dstRel = 'archive/' . $this->getHashPath() . $dstArchiveName; |
1057 | | - } else { |
1058 | | - $dstRel = $this->getRel(); |
1059 | | - } |
1060 | | - |
| 1070 | + |
1061 | 1071 | $archiveName = wfTimestamp( TS_MW ) . '!'. $this->getName(); |
1062 | 1072 | $archiveRel = 'archive/' . $this->getHashPath() . $archiveName; |
1063 | 1073 | $flags = $flags & File::DELETE_SOURCE ? LocalRepo::DELETE_SOURCE : 0; |