From 2a650c49eedbb6d2647f38bba8efdb2379f3a692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tony=20Saraj=C3=A4rvi?= Date: Thu, 21 Sep 2017 08:24:45 +0300 Subject: Provisioning: Fix usage of DownloadURL to throw errors In case DownloadURL failed it's shasum check, it printed an error and threw an exit 1. This exit 1 was never handled in the calling scripts and went ignored. It was also not passed forward as it was inside a try-catch statement. Change-Id: Iae4fd6aefb75c07623ec86dc570f0a46fec659b4 Reviewed-by: Heikki Halmet --- coin/provisioning/common/InstallAppFromCompressedFileFromURL.sh | 6 +++++- coin/provisioning/common/InstallFromCompressedFileFromURL.sh | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'coin') diff --git a/coin/provisioning/common/InstallAppFromCompressedFileFromURL.sh b/coin/provisioning/common/InstallAppFromCompressedFileFromURL.sh index bee16dd2..2af2db10 100644 --- a/coin/provisioning/common/InstallAppFromCompressedFileFromURL.sh +++ b/coin/provisioning/common/InstallAppFromCompressedFileFromURL.sh @@ -42,6 +42,7 @@ source "${BASH_SOURCE%/*}/try_catch.sh" # shellcheck source=DownloadURL.sh source "${BASH_SOURCE%/*}/DownloadURL.sh" +ExceptionDownload=99 ExceptionCreateTmpFile=100 ExceptionCreateTmpDirectory=101 ExceptionUncompress=102 @@ -80,7 +81,7 @@ function InstallAppFromCompressedFileFromURL { else targetDirectory=$(mktemp -d) || throw $ExceptionCreateTmpDirectory fi - DownloadURL "$url" "$url_alt" "$expectedSha1" "$targetFile" + (DownloadURL "$url" "$url_alt" "$expectedSha1" "$targetFile") || throw $ExceptionDownload echo "Uncompress $targetFile" case $extension in "tar.gz") @@ -103,6 +104,9 @@ function InstallAppFromCompressedFileFromURL { catch || { case $ex_code in + $ExceptionDownload) + exit 1; + ;; $ExceptionCreateTmpFile) echo "Failed to create temporary file" exit 1; diff --git a/coin/provisioning/common/InstallFromCompressedFileFromURL.sh b/coin/provisioning/common/InstallFromCompressedFileFromURL.sh index e3716597..df84431a 100644 --- a/coin/provisioning/common/InstallFromCompressedFileFromURL.sh +++ b/coin/provisioning/common/InstallFromCompressedFileFromURL.sh @@ -38,6 +38,7 @@ source "${BASH_SOURCE%/*}/try_catch.sh" # shellcheck source=DownloadURL.sh source "${BASH_SOURCE%/*}/DownloadURL.sh" +ExceptionDownload=99 ExceptionCreateTmpFile=100 ExceptionCreateTmpDirectory=101 ExceptionUncompress=102 @@ -66,7 +67,7 @@ function InstallFromCompressedFileFromURL { echo "Creating temporary file and directory" targetFile=$(mktemp "$TMPDIR$(uuidgen)XXXXX.$extension") || throw $ExceptionCreateTmpFile targetDirectory=$(mktemp -d) || throw $ExceptionCreateTmpDirectory - DownloadURL "$url" "$url_alt" "$expectedSha1" "$targetFile" + (DownloadURL "$url" "$url_alt" "$expectedSha1" "$targetFile") || throw $ExceptionDownload echo "Uncompress $targetFile" case $extension in "tar.gz") @@ -90,6 +91,9 @@ function InstallFromCompressedFileFromURL { catch || { case $ex_code in + $ExceptionDownload) + exit 1; + ;; $ExceptionCreateTmpFile) echo "Failed to create temporary file" exit 1; -- cgit v1.2.3