Merge "Improve logging for Pdf's retrieveMetadata.sh"

This commit is contained in:
jenkins-bot 2024-03-18 17:23:37 +00:00 committed by Gerrit Code Review
commit 6fd16808fb
2 changed files with 20 additions and 4 deletions

View file

@ -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
View 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