Followup 1cf5a6e: use $wgResourceBasePath to refer to resources/assets, not $wgScriptPath
[lhc/web/wiklou.git] / includes / filerepo / file / File.php
index f9e0a2d..b574c5e 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()
                );
@@ -1312,9 +1328,9 @@ abstract class File {
         * @return ThumbnailImage
         */
        function iconThumb() {
-               global $wgScriptPath, $IP;
-               $assetsPath = "$wgScriptPath/assets/file-type-icons/";
-               $assetsDirectory = "$IP/assets/file-type-icons/";
+               global $wgResourceBasePath, $IP;
+               $assetsPath = "$wgResourceBasePath/resources/assets/file-type-icons/";
+               $assetsDirectory = "$IP/resources/assets/file-type-icons/";
 
                $try = array( 'fileicon-' . $this->getExtension() . '.png', 'fileicon.png' );
                foreach ( $try as $icon ) {