From 45ee5c99d52630e9c5321e786efa77121897a8a2 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Sun, 27 Jul 2014 20:23:55 -0300 Subject: [PATCH] Make GetLocalFileCopy pool counter call from tiff be generic I was to make PagedTiffHandler subclass TransformationalImageHandler. The biggest thing that's different is the pool counter call. However, given that a file is just as expensive in terms of network bandwidth regardless of its type, seems to make sense to make this check generic. Change-Id: I7e4a4769edaa4742803df407b9c719c54fb77de3 --- includes/filerepo/file/File.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index f9e0a2dc93..11a3e5c035 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -1231,9 +1231,25 @@ abstract class File { } } + // Thumbnailing a very large file could result in network saturation if + // everyone does it at once. + if ( $this->getSize() >= 1e7 ) { // 10MB + $that = $this; + $work = new PoolCounterWorkViaCallback( 'GetLocalFileCopy', sha1( $this->getName() ), + array( + 'doWork' => function() use ( $that ) { + return $that->getLocalRefPath(); + } + ) + ); + $srcPath = $work->execute(); + } else { + $srcPath = $this->getLocalRefPath(); + } + // Original file return array( - 'path' => $this->getLocalRefPath(), + 'path' => $srcPath, 'width' => $this->getWidth(), 'height' => $this->getHeight() ); -- 2.20.1