Do not complain about existing empty files

Sometimes we pre-create the target filename using mktemp. In that case of
course the hash will not match, so avoid comparing.

Change-Id: Id0feb0178d659e03f5ceb000f738167cdc28a3ec
Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
This commit is contained in:
Dimitrios Apostolou
2020-02-07 16:00:40 +01:00
parent 25fcda6ff3
commit b018b841c1

View File

@@ -100,20 +100,27 @@ DownloadURL () {
targetFile=$4 targetFile=$4
fi fi
if VerifyHash "$targetFile" "$expectedHash" # If a non-empty file already exists
if [ -s "$targetFile" ]
then then
echo "Skipping download, found and validated existing file: $targetFile" if VerifyHash "$targetFile" "$expectedHash"
else
echo "Downloading from primary URL: $url"
if ! Download "$url" "$targetFile"
then then
echo "FAIL! to download, trying alternative URL: $url2" 1>&2 echo "Skipping download, found and validated existing file: $targetFile"
if ! Download "$url2" "$targetFile" return
then else
echo 'FAIL! to download even from alternative URL' 1>&2 echo "WARNING: Non-empty but different file found at destination; will re-download and overwrite file: $targetFile"
return 1
fi
fi fi
VerifyHash "$targetFile" "$expectedHash"
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 even from alternative URL' 1>&2
return 1
fi
fi
VerifyHash "$targetFile" "$expectedHash"
} }