X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Ffilerepo%2FFileRepo.php;h=4ab913da0cb791d7bd669944f82c5cd0cc9bd498;hb=5c1b3768ed022978edb038df14e0f15874eea7b4;hp=15821ea4dd7a87eb2cdd44b0174c6f81b360fd3d;hpb=0a510ed072b68c009cd97307b77eef8a6279ea2a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 15821ea4dd..4ab913da0c 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -533,11 +533,10 @@ class FileRepo { public function findFileFromKey( $sha1, $options = [] ) { $time = isset( $options['time'] ) ? $options['time'] : false; # First try to find a matching current version of a file... - if ( $this->fileFactoryKey ) { - $img = call_user_func( $this->fileFactoryKey, $sha1, $this, $time ); - } else { + if ( !$this->fileFactoryKey ) { return false; // find-by-sha1 not supported } + $img = call_user_func( $this->fileFactoryKey, $sha1, $this, $time ); if ( $img && $img->exists() ) { return $img; } @@ -815,7 +814,6 @@ class FileRepo { * @param string $dstZone Destination zone * @param string $dstRel Destination relative path * @param int $flags Bitwise combination of the following flags: - * self::DELETE_SOURCE Delete the source file after upload * self::OVERWRITE Overwrite an existing destination file instead of failing * self::OVERWRITE_SAME Overwrite the file if the destination exists and has the * same contents as the source @@ -838,7 +836,6 @@ class FileRepo { * * @param array $triplets (src, dest zone, dest rel) triplets as per store() * @param int $flags Bitwise combination of the following flags: - * self::DELETE_SOURCE Delete the source file after upload * self::OVERWRITE Overwrite an existing destination file instead of failing * self::OVERWRITE_SAME Overwrite the file if the destination exists and has the * same contents as the source @@ -849,11 +846,14 @@ class FileRepo { public function storeBatch( array $triplets, $flags = 0 ) { $this->assertWritableRepo(); // fail out if read-only + if ( $flags & self::DELETE_SOURCE ) { + throw new InvalidArgumentException( "DELETE_SOURCE not supported in " . __METHOD__ ); + } + $status = $this->newGood(); $backend = $this->backend; // convenience $operations = []; - $sourceFSFilesToDelete = []; // cleanup for disk source files // Validate each triplet and get the store operation... foreach ( $triplets as $triplet ) { list( $srcPath, $dstZone, $dstRel ) = $triplet; @@ -881,12 +881,9 @@ class FileRepo { // Get the appropriate file operation if ( FileBackend::isStoragePath( $srcPath ) ) { - $opName = ( $flags & self::DELETE_SOURCE ) ? 'move' : 'copy'; + $opName = 'copy'; } else { $opName = 'store'; - if ( $flags & self::DELETE_SOURCE ) { - $sourceFSFilesToDelete[] = $srcPath; - } } $operations[] = [ 'op' => $opName, @@ -903,12 +900,6 @@ class FileRepo { $opts['nonLocking'] = true; } $status->merge( $backend->doOperations( $operations, $opts ) ); - // Cleanup for disk source files... - foreach ( $sourceFSFilesToDelete as $file ) { - MediaWiki\suppressWarnings(); - unlink( $file ); // FS cleanup - MediaWiki\restoreWarnings(); - } return $status; } @@ -1594,12 +1585,13 @@ class FileRepo { * * @param string $virtualUrl * @param array $headers Additional HTTP headers to send on success + * @param array $optHeaders HTTP request headers (if-modified-since, range, ...) * @return Status * @since 1.27 */ - public function streamFileWithStatus( $virtualUrl, $headers = [] ) { + public function streamFileWithStatus( $virtualUrl, $headers = [], $optHeaders = [] ) { $path = $this->resolveToStoragePath( $virtualUrl ); - $params = [ 'src' => $path, 'headers' => $headers ]; + $params = [ 'src' => $path, 'headers' => $headers, 'options' => $optHeaders ]; return $this->backend->streamFile( $params ); }