Skip to content

Commit

Permalink
feat: Retry failed downloads (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
kroese authored Nov 11, 2024
1 parent d093e4f commit b30479a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
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

0 comments on commit b30479a

Please sign in to comment.