mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/PdfHandler
synced 2024-11-24 08:14:37 +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' );
|
return $this->doThumbError( $width, $height, 'thumbnail_dest_directory' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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();
|
$srcPath = $image->getLocalRefPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $srcPath === false ) { // could not download original
|
||||||
|
return $this->doThumbError( $width, $height, 'filemissing' );
|
||||||
|
}
|
||||||
|
|
||||||
$cmd = '(' . wfEscapeShellArg(
|
$cmd = '(' . wfEscapeShellArg(
|
||||||
$wgPdfProcessor,
|
$wgPdfProcessor,
|
||||||
|
|
Loading…
Reference in a new issue