From 69ce95d61ee35717da365c4f1362951ee5dd0b9f Mon Sep 17 00:00:00 2001 From: Gustavo Neves Date: Mon, 15 May 2017 03:22:28 -0300 Subject: [PATCH] adding check and abort process if the temp file already exists, prob has a 0.000000000000001% chance of happening, but that is not zero anyways --- pdfScale.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pdfScale.sh b/pdfScale.sh index 3a8ac6d..4d1c40a 100755 --- a/pdfScale.sh +++ b/pdfScale.sh @@ -70,6 +70,7 @@ EXIT_MISSING_DEPENDENCY=25 EXIT_IMAGEMAGIK_NOT_FOUND=26 EXIT_MAC_MDLS_NOT_FOUND=27 EXIT_PDFINFO_NOT_FOUND=28 +EXIT_TEMP_FILE_EXISTS=40 EXIT_INVALID_PAPER_SIZE=50 @@ -91,6 +92,10 @@ main() { if isMixedMode; then outputFile="$OUTFILEPDF" # backup outFile name tempFile="${OUTFILEPDF%.pdf}.$tempSuffix" # set a temp file name + if isFile "$tempFile"; then + printError $'Error! Temporary file name already exists!\n'"File: $tempFile"$'\nAborting execution to avoid overwriting the file.\nPlease Try again...' + exit $EXIT_TEMP_FILE_EXISTS + fi OUTFILEPDF="$tempFile" # set output to tmp file pageResize # resize to tmp file finalRet=$?