Allow using PoolCounter for large PDF local downloads

Change-Id: Ifee3a5764b32ef31e4ed9edb183272ebb89bd11b
This commit is contained in:
Aaron Schulz 2014-03-15 10:50:37 -07:00
parent 7e59dedf95
commit ce77a57144

View file

@ -165,7 +165,24 @@ class PdfHandler extends ImageHandler {
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,