Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sn4k3/UVtools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Conceição <Tiago_caza@hotmail.com>2022-10-30 19:45:45 +0300
committerTiago Conceição <Tiago_caza@hotmail.com>2022-10-30 19:45:45 +0300
commit890f637b9da4dc85d9d42b84b9b5bb54e9a3fd9f (patch)
treed4f71c2c762b1ede7acc6f84874875e2f72dfaef /Scripts
parent4015bd2214c111f807e6f7002322a999a2df2ad4 (diff)
Validate download file
Diffstat (limited to 'Scripts')
-rw-r--r--Scripts/install-uvtools.sh9
1 files changed, 5 insertions, 4 deletions
diff --git a/Scripts/install-uvtools.sh b/Scripts/install-uvtools.sh
index dfe23c5..7133dcd 100644
--- a/Scripts/install-uvtools.sh
+++ b/Scripts/install-uvtools.sh
@@ -39,11 +39,12 @@ downloaduvtools(){
echo "Downloading: $download_url"
curl -L --retry 4 $download_url -o "$tmpfile"
- if [ -n "$2" ]; then
+ download_size="$(curl -s -L -I $download_url | gawk -v IGNORECASE=1 '/^Content-Length/ { print $2 }' | tail -n1 | tr -d '\r')"
+ if [ -n "$download_size" ]; then
echo "- Validating file"
- size="$(get_filesize "$tmpfile")"
- if [ "$2" -ne "$size" ]; then
- echo "Error: File verification failed, expecting $2 bytes but downloaded $size bytes. Please re-run the script."
+ local filesize="$(get_filesize "$tmpfile")"
+ if [ "$download_size" -ne "$filesize" ]; then
+ echo "Error: File verification failed, expecting $download_size bytes but downloaded $filesize bytes. Please re-run the script."
rm -f "$tmpfile"
exit -1
fi