From 9fbdc709bea0c908eb5ade7b43ded46ad986e5f9 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 21 Jul 2026 06:03:23 +0200 Subject: [PATCH] feat: Improve download function --- src/install.sh | 42 +++++++++--------------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/src/install.sh b/src/install.sh index f4eda90..4990f47 100644 --- a/src/install.sh +++ b/src/install.sh @@ -9,7 +9,7 @@ downloadFile() { local expected="${4:-0}" local connections="${5:-1}" local dest="$STORAGE/$base" - local msg total size + local msg if [ -z "$name" ]; then msg="Downloading image" @@ -19,38 +19,13 @@ downloadFile() { info "Downloading $name..." fi - if downloadToFile \ - "$url" \ - "$dest" \ - "$msg" \ - "$expected" \ - "$connections" \ - "Y"; then - return 0 - fi - - local rc=$? - (( rc != 0 )) && return "$rc" - - if ! total=$(stat -c%s -- "$dest"); then - error "Failed to determine downloaded file size: $dest" - return 1 - fi - - size=$(formatBytes "$total") || return 1 - - if (( total < 100000 )); then - - error "Invalid image file: is only $size ?" - - if ! rm -f -- "$dest" "$dest.aria2"; then - warn "failed to remove invalid download \"$dest\"!" - fi - - return 1 - fi - - return 0 + downloadToFile \ + "$url" \ + "$dest" \ + "$msg" \ + "$expected" \ + "$connections" \ + "Y" } bootFile() { @@ -207,6 +182,7 @@ downloadImage() { "$connections" \ "5" \ "${name:-$base}" \ + "$SIZE" \ "$URL" \ "$base" \ "$name" \