From 472e8e2d16d706e746f718f7d4b3bf86af5af1f1 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Fri, 18 Nov 2016 12:32:54 +0100 Subject: Fix gunzip code, for PDF URIs that let us retrieve a compressed PDF. --- bin/impressive-display | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/impressive-display b/bin/impressive-display index c41ba3d..803701d 100755 --- a/bin/impressive-display +++ b/bin/impressive-display @@ -345,12 +345,18 @@ function download_pdffile { if [ -n "$PDF_URL_CREDS" ]; then creds="-u $PDF_URL_CREDS" fi - curl $creds "$PDF_URI" 1> "$pdffile_downloaded" 2>/dev/null + + DOWNLOADED_FILE="$workdir/$(basename $PDF_URI)" + if ! curl $creds "$PDF_URI" 1> "$DOWNLOADED_FILE"; then + $OUTPUT "The curl tool failed in retrieving PDF file." + fi # is the PDF file gzipped? - if echo $(basename $pdffile_downloaded) | grep -E ".*\.gz"; then - pdffile_downloaded=${pdffile_downloaded/.gz/} - gunzip $workdir/$(basename $pdffile_downloaded).gz + if echo "$DOWNLOADED_FILE" | grep -E '.*\.gz$'; then + gunzip -f "$DOWNLOADED_FILE" + mv "${DOWNLOADED_FILE/.gz/}" "$pdffile_downloaded" + else + mv "${DOWNLOADED_FILE}" "$pdffile_downloaded" fi if pdfinfo "$pdffile_downloaded" 1>/dev/null 2>/dev/null; then -- cgit v1.2.3