diff options
Diffstat (limited to 'coin/provisioning/common')
-rwxr-xr-x | coin/provisioning/common/unix/DownloadURL.sh | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/coin/provisioning/common/unix/DownloadURL.sh b/coin/provisioning/common/unix/DownloadURL.sh index 5a3130af..1d48a565 100755 --- a/coin/provisioning/common/unix/DownloadURL.sh +++ b/coin/provisioning/common/unix/DownloadURL.sh @@ -100,20 +100,27 @@ DownloadURL () { targetFile=$4 fi - if VerifyHash "$targetFile" "$expectedHash" + # If a non-empty file already exists + if [ -s "$targetFile" ] then - echo "Skipping download, found and validated existing file: $targetFile" - else - echo "Downloading from primary URL: $url" - if ! Download "$url" "$targetFile" + if VerifyHash "$targetFile" "$expectedHash" + then + echo "Skipping download, found and validated existing file: $targetFile" + return + else + echo "WARNING: Non-empty but different file found at destination; will re-download and overwrite file: $targetFile" + fi + fi + + echo "Downloading from primary URL: $url" + if ! Download "$url" "$targetFile" + then + echo "FAIL! to download, trying alternative URL: $url2" 1>&2 + if ! Download "$url2" "$targetFile" then - echo "FAIL! to download, trying alternative URL: $url2" 1>&2 - if ! Download "$url2" "$targetFile" - then - echo 'FAIL! to download even from alternative URL' 1>&2 - return 1 - fi + echo 'FAIL! to download even from alternative URL' 1>&2 + return 1 fi - VerifyHash "$targetFile" "$expectedHash" fi + VerifyHash "$targetFile" "$expectedHash" } |