Set isExpensiveToThumbnail for the djvu handler
authorAaron Schulz <aschulz@wikimedia.org>
Sun, 10 May 2015 19:49:43 +0000 (12:49 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Sun, 10 May 2015 19:49:47 +0000 (12:49 -0700)
* This makes FileRenderExpensive pool logic apply for large files
  to cut down on DB load from getMetaTree()

Bug: T96360
Change-Id: If892d77077607ffcaba0510355175a1e4d780ae9

includes/media/DjVu.php

index 011fb2a..5b57952 100644 (file)
@@ -27,6 +27,8 @@
  * @ingroup Media
  */
 class DjVuHandler extends ImageHandler {
+       const EXPENSIVE_SIZE_LIMIT = 10485760; // 10MiB
+
        /**
         * @return bool
         */
@@ -49,6 +51,15 @@ class DjVuHandler extends ImageHandler {
                return true;
        }
 
+       /**
+        * True if creating thumbnails from the file is large or otherwise resource-intensive.
+        * @param File $file
+        * @return bool
+        */
+       public function isExpensiveToThumbnail( $file ) {
+               return $file->getSize() > static::EXPENSIVE_SIZE_LIMIT;
+       }
+
        /**
         * @param File $file
         * @return bool