mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/PdfHandler
synced 2024-11-24 00:07:10 +00:00
Allow using PoolCounter for large PDF local downloads
Change-Id: Ifee3a5764b32ef31e4ed9edb183272ebb89bd11b
This commit is contained in:
parent
7e59dedf95
commit
ce77a57144
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue