jenkins-bot has submitted this change and it was merged.

Change subject: Allow using PoolCounter for large PDF local downloads
......................................................................


Allow using PoolCounter for large PDF local downloads

Change-Id: Ifee3a5764b32ef31e4ed9edb183272ebb89bd11b
---
M PdfHandler_body.php
1 file changed, 18 insertions(+), 1 deletion(-)

Approvals:
  Chad: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/PdfHandler_body.php b/PdfHandler_body.php
index 495f3bb..32252a5 100644
--- a/PdfHandler_body.php
+++ b/PdfHandler_body.php
@@ -165,7 +165,24 @@
                        return $this->doThumbError( $width, $height, 
'thumbnail_dest_directory' );
                }
 
-               $srcPath = $image->getLocalRefPath();
+               // Thumbnail extraction is very inefficient for large files.
+               // Provide a way to pool count limit the number of downloaders.
+               if ( $image->getSize() >= 1e7 ) { // 10MB
+                       $work = new PoolCounterWorkViaCallback( 'downloadpdf', 
sha1( $image->getName() ),
+                               array(
+                                       'doWork' => function() use ( $image ) {
+                                               return 
$image->getLocalRefPath();
+                                       }
+                               )
+                       );
+                       $srcPath = $work->execute();
+               } else {
+                       $srcPath = $image->getLocalRefPath();
+               }
+
+               if ( $srcPath === false ) { // could not download original
+                       return $this->doThumbError( $width, $height, 
'filemissing' );
+               }
 
                $cmd = '(' . wfEscapeShellArg(
                        $wgPdfProcessor,

-- 
To view, visit https://gerrit.wikimedia.org/r/118819
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifee3a5764b32ef31e4ed9edb183272ebb89bd11b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PdfHandler
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Chad <ch...@wikimedia.org>
Gerrit-Reviewer: Faidon Liambotis <fai...@wikimedia.org>
Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to