Make GetLocalFileCopy pool counter call from tiff be generic
[lhc/web/wiklou.git] / includes / filerepo / file / File.php
index f9e0a2d..11a3e5c 100644 (file)
@@ -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()
                );