Pārlūkot izejas kodu

Add check if download was successfull

Jaap Marcus 3 gadi atpakaļ
vecāks
revīzija
c4bbb9db96
1 mainītis faili ar 7 papildinājumiem un 0 dzēšanām
  1. 7 0
      src/hst_autocompile.sh

+ 7 - 0
src/hst_autocompile.sh

@@ -12,7 +12,9 @@
 clear
 clear
 
 
 # Define download function
 # Define download function
+set -e 
 download_file() {
 download_file() {
+    set +e 
     local url=$1
     local url=$1
     local destination=$2
     local destination=$2
     local force=$3
     local force=$3
@@ -50,6 +52,11 @@ download_file() {
     if [ ! -f "$ARCHIVE_DIR/$filename" ]; then
     if [ ! -f "$ARCHIVE_DIR/$filename" ]; then
         [ "$HESTIA_DEBUG" ] && >&2 echo DEBUG: wget $url -q $dstopt --show-progress --progress=bar:force --limit-rate=3m
         [ "$HESTIA_DEBUG" ] && >&2 echo DEBUG: wget $url -q $dstopt --show-progress --progress=bar:force --limit-rate=3m
         wget $url -q $dstopt --show-progress --progress=bar:force --limit-rate=3m
         wget $url -q $dstopt --show-progress --progress=bar:force --limit-rate=3m
+        if [ $? -ne 0 ]; then
+            >&2 echo "[!] Archive $ARCHIVE_DIR/$filename is corrupted and exit script";
+            rm -f $ARCHIVE_DIR/$filename
+            exit 1;
+        fi
     fi
     fi
 
 
     if [ ! -z "$destination" ] && [ "$is_archive" = "true" ]; then
     if [ ! -z "$destination" ] && [ "$is_archive" = "true" ]; then