Index: branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php |
— | — | @@ -635,7 +635,7 @@ |
636 | 636 | /** |
637 | 637 | * Combines files from severals storage paths into a new file in the backend. |
638 | 638 | * Parameters similar to FileBackend::concatenate(), which include: |
639 | | - * sources : ordered source storage paths (e.g. chunk1,chunk2,...) |
| 639 | + * sources : ordered source storage paths (e.g. chunk1, chunk2, ...) |
640 | 640 | * dst : destination storage path |
641 | 641 | * overwriteDest : do nothing and pass if an identical file exists at destination |
642 | 642 | */ |
Index: branches/FileBackend/phase3/includes/filerepo/backend/FSFileBackend.php |
— | — | @@ -427,7 +427,10 @@ |
428 | 428 | return $status; |
429 | 429 | } |
430 | 430 | |
431 | | - $ok = StreamFile::stream( $source, array(), false ); |
| 431 | + $extraHeaders = isset( $params['headers'] ) |
| 432 | + ? $params['headers'] |
| 433 | + : array(); |
| 434 | + $ok = StreamFile::stream( $source, $extraHeaders, false ); |
432 | 435 | if ( !$ok ) { |
433 | 436 | $status->fatal( 'backend-fail-stream', $params['src'] ); |
434 | 437 | return $status; |
Index: branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php |
— | — | @@ -186,7 +186,8 @@ |
187 | 187 | * must be sent if streaming began, while none should be sent otherwise. |
188 | 188 | * Implementations should flush the output buffer before sending data. |
189 | 189 | * $params include: |
190 | | - * src : source storage path |
| 190 | + * src : source storage path |
| 191 | + * headers : additional headers to send on success |
191 | 192 | * |
192 | 193 | * @param Array $params |
193 | 194 | * @return Status |
— | — | @@ -306,7 +307,7 @@ |
307 | 308 | * Combines files from severals storage paths into a new file in the backend. |
308 | 309 | * Do not call this function from places outside FileBackend and FileOp. |
309 | 310 | * $params include: |
310 | | - * src : source storage path |
| 311 | + * sources : ordered source storage paths (e.g. chunk1, chunk2, ...) |
311 | 312 | * dst : destination storage path |
312 | 313 | * overwriteDest : do nothing and pass if an identical file exists at destination |
313 | 314 | * |
Index: branches/FileBackend/phase3/includes/filerepo/FileRepo.php |
— | — | @@ -1081,6 +1081,7 @@ |
1082 | 1082 | * If a path is a virtual URL, resolve it to a storage path. |
1083 | 1083 | * Otherwise, just return the path as it is. |
1084 | 1084 | * |
| 1085 | + * @param $path string |
1085 | 1086 | * @return string |
1086 | 1087 | * @throws MWException |
1087 | 1088 | */ |
— | — | @@ -1095,6 +1096,7 @@ |
1096 | 1097 | * Get a local FS copy of a file with a given virtual URL/storage path. |
1097 | 1098 | * Returns null on failure. |
1098 | 1099 | * |
| 1100 | + * @param $virtualUrl string |
1099 | 1101 | * @return TempFSFile|null |
1100 | 1102 | */ |
1101 | 1103 | public function getLocalCopy( $virtualUrl ) { |
— | — | @@ -1117,7 +1119,7 @@ |
1118 | 1120 | /** |
1119 | 1121 | * Get the timestamp of a file with a given virtual URL/storage path |
1120 | 1122 | * |
1121 | | - * @param $virtualUrl |
| 1123 | + * @param $virtualUrl string |
1122 | 1124 | * @return string|false |
1123 | 1125 | */ |
1124 | 1126 | public function getFileTimestamp( $virtualUrl ) { |
— | — | @@ -1128,7 +1130,7 @@ |
1129 | 1131 | /** |
1130 | 1132 | * Get the sha1 of a file with a given virtual URL/storage path |
1131 | 1133 | * |
1132 | | - * @param $virtualUrl |
| 1134 | + * @param $virtualUrl string |
1133 | 1135 | * @return string|false |
1134 | 1136 | */ |
1135 | 1137 | public function getFileSha1( $virtualUrl ) { |
— | — | @@ -1141,6 +1143,19 @@ |
1142 | 1144 | } |
1143 | 1145 | |
1144 | 1146 | /** |
| 1147 | + * Attempt to stream a file with the given virtual URL/storage path |
| 1148 | + * |
| 1149 | + * @param $virtualUrl string |
| 1150 | + * @param $headers Array Extra headers to send on success |
| 1151 | + * @return bool Success |
| 1152 | + */ |
| 1153 | + public function streamFile( $virtualUrl, $headers = array() ) { |
| 1154 | + $path = $this->resolveToStoragePath( $virtualUrl ); |
| 1155 | + $params = array( 'src' => $path, 'headers' => $headers ); |
| 1156 | + return $this->backend->streamFile( $params )->isOK(); |
| 1157 | + } |
| 1158 | + |
| 1159 | + /** |
1145 | 1160 | * Call a callback function for every public file in the repository. |
1146 | 1161 | * May use either the database or the filesystem. |
1147 | 1162 | * |
Index: branches/FileBackend/phase3/thumb.php |
— | — | @@ -111,9 +111,9 @@ |
112 | 112 | // Calculate time |
113 | 113 | wfSuppressWarnings(); |
114 | 114 | $imsUnix = strtotime( $imsString ); |
115 | | - $stat = stat( $sourcePath ); |
116 | 115 | wfRestoreWarnings(); |
117 | | - if ( $stat['mtime'] <= $imsUnix ) { |
| 116 | + $sourceTsUnix = wfTimestamp( TS_UNIX, $img->getTimestamp() ); |
| 117 | + if ( $sourceTsUnix <= $imsUnix ) { |
118 | 118 | header( 'HTTP/1.1 304 Not Modified' ); |
119 | 119 | wfProfileOut( __METHOD__ ); |
120 | 120 | return; |
— | — | @@ -125,8 +125,8 @@ |
126 | 126 | $thumbName = $img->thumbName( $params ); |
127 | 127 | if ( $thumbName !== false ) { // valid params? |
128 | 128 | $thumbPath = $img->getThumbPath( $thumbName ); |
129 | | - if ( is_file( $thumbPath ) ) { |
130 | | - StreamFile::stream( $thumbPath, $headers ); |
| 129 | + if ( $img->getRepo()->fileExists( $thumbPath ) ) { |
| 130 | + $img->getRepo()->streamFile( $thumbPath, $headers ); |
131 | 131 | wfProfileOut( __METHOD__ ); |
132 | 132 | return; |
133 | 133 | } |
— | — | @@ -153,7 +153,7 @@ |
154 | 154 | $errorMsg = $thumb->getHtmlMsg(); |
155 | 155 | } elseif ( !$thumb->getPath() ) { |
156 | 156 | $errorMsg = wfMsgHtml( 'thumbnail_error', 'No path supplied in thumbnail object' ); |
157 | | - } elseif ( $thumb->getPath() == $img->getPath() ) { |
| 157 | + } elseif ( $thumb->getPath() == $img->getLocalCopyPath() ) { |
158 | 158 | $errorMsg = wfMsgHtml( 'thumbnail_error', 'Image was not scaled, ' . |
159 | 159 | 'is the requested width bigger than the source?' ); |
160 | 160 | } |