Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 9 additions & 33 deletions src/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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() {
Expand Down Expand Up @@ -207,6 +182,7 @@ downloadImage() {
"$connections" \
"5" \
"${name:-$base}" \
"$SIZE" \
"$URL" \
"$base" \
"$name" \
Expand Down