Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Retry failed downloads #219

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM scratch
COPY --from=qemux/qemu-arm:2.18 / /
COPY --from=qemux/qemu-arm:2.19 / /

ARG VERSION_ARG="0.0"
ARG DEBCONF_NOWARNINGS="yes"
Expand Down
31 changes: 30 additions & 1 deletion src/mido.sh
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ getWindows() {
language=$(getLanguage "$lang" "desc")
edition=$(printEdition "$version" "$desc")

local msg="Requesting $desc from Microsoft server..."
local msg="Requesting $desc from the Microsoft servers..."
info "$msg" && html "$msg"

case "${version,,}" in
Expand Down Expand Up @@ -610,13 +610,18 @@ downloadImage() {
local iso="$1"
local version="$2"
local lang="$3"
local delay=5
local tried="n"
local success="n"
local url sum size base desc language
local msg="Will retry after $delay seconds..."

if [[ "${version,,}" == "http"* ]]; then
base=$(basename "$iso")
desc=$(fromFile "$base")
downloadFile "$iso" "$version" "" "" "" "$desc" && return 0
info "$msg" && html "$msg" && sleep "$delay"
downloadFile "$iso" "$version" "" "" "" "$desc" && return 0
rm -f "$iso"
return 1
fi
Expand All @@ -637,11 +642,23 @@ downloadImage() {
fi

if isMido "$version" "$lang"; then

tried="y"
success="n"

if getWindows "$version" "$lang" "$desc"; then
success="y"
else
info "$msg" && html "$msg" && sleep "$delay"
getWindows "$version" "$lang" "$desc" && success="y"
fi

if [[ "$success" == "y" ]]; then
size=$(getMido "$version" "$lang" "size" )
sum=$(getMido "$version" "$lang" "sum")
downloadFile "$iso" "$MIDO_URL" "$sum" "$size" "$lang" "$desc" && return 0
info "$msg" && html "$msg" && sleep "$delay"
downloadFile "$iso" "$MIDO_URL" "$sum" "$size" "$lang" "$desc" && return 0
rm -f "$iso"
fi
fi
Expand All @@ -655,10 +672,20 @@ downloadImage() {
fi

tried="y"
success="n"

if getESD "$TMP/esd" "$version" "$lang" "$desc"; then
success="y"
else
info "$msg" && html "$msg" && sleep "$delay"
getESD "$TMP/esd" "$version" "$lang" "$desc" && success="y"
fi

if [[ "$success" == "y" ]]; then
ISO="${ISO%.*}.esd"
downloadFile "$ISO" "$ESD" "$ESD_SUM" "$ESD_SIZE" "$lang" "$desc" && return 0
info "$msg" && html "$msg" && sleep "$delay"
downloadFile "$ISO" "$ESD" "$ESD_SUM" "$ESD_SIZE" "$lang" "$desc" && return 0
rm -f "$ISO"
ISO="$iso"
fi
Expand All @@ -677,6 +704,8 @@ downloadImage() {
size=$(getSize "$i" "$version" "$lang")
sum=$(getHash "$i" "$version" "$lang")
downloadFile "$iso" "$url" "$sum" "$size" "$lang" "$desc" && return 0
info "$msg" && html "$msg" && sleep "$delay"
downloadFile "$iso" "$url" "$sum" "$size" "$lang" "$desc" && return 0
rm -f "$iso"
fi

Expand Down