mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/PdfHandler
synced 2024-11-27 09:42:16 +00:00
Merge "Improve logging for Pdf's retrieveMetadata.sh"
This commit is contained in:
commit
6fd16808fb
|
@ -132,6 +132,13 @@ class PdfImage {
|
|||
MediaWikiServices::getInstance()->getStatsdDataFactory()
|
||||
->increment( 'pdfhandler.shell.retrieve_meta_data' );
|
||||
|
||||
// Metadata retrieval is allowed to fail, but we'd like to know why
|
||||
if ( $result->getExitCode() != 0 ) {
|
||||
wfDebug( __METHOD__ . ': retrieveMetaData.sh' .
|
||||
"\n\nExitcode: " . $result->getExitCode() . "\n\n"
|
||||
. $result->getStderr() );
|
||||
}
|
||||
|
||||
$resultMeta = $result->getFileContents( 'meta' );
|
||||
$resultPages = $result->getFileContents( 'pages' );
|
||||
if ( $resultMeta !== null || $resultPages !== null ) {
|
||||
|
|
17
scripts/retrieveMetaData.sh
Normal file → Executable file
17
scripts/retrieveMetaData.sh
Normal file → Executable file
|
@ -13,14 +13,23 @@ runInfo() {
|
|||
"$PDFHANDLER_INFO" \
|
||||
-enc 'UTF-8' \
|
||||
-meta \
|
||||
file.pdf > meta
|
||||
file.pdf 1> meta
|
||||
|
||||
# Check for errors and forward them
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# Report metadata as UTF-8 text...and report page sizes for all pages
|
||||
"$PDFHANDLER_INFO" \
|
||||
-enc 'UTF-8' \
|
||||
-l 9999999 \
|
||||
file.pdf > pages
|
||||
file.pdf 1> pages
|
||||
|
||||
# Check for errors and forward them
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1;
|
||||
fi
|
||||
}
|
||||
|
||||
runToText() {
|
||||
|
@ -34,10 +43,10 @@ runToText() {
|
|||
echo $? > text_exit_code
|
||||
}
|
||||
|
||||
if [ -x "$PDFHANDLER_INFO" ]; then
|
||||
if [ -x "$(command -v $PDFHANDLER_INFO)" ]; then
|
||||
runInfo
|
||||
fi
|
||||
|
||||
if [ -x "$PDFHANDLER_TOTEXT" ]; then
|
||||
if [ -x "$(command -v $PDFHANDLER_TOTEXT)" ]; then
|
||||
runToText
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue