fix: Simplify error propagation boundaries (#2104)

This commit is contained in:
Kroese
2026-08-07 19:52:06 +02:00
committed by GitHub
parent ff8c17ad04
commit be96767802
3 changed files with 176 additions and 231 deletions
+39 -56
View File
@@ -369,7 +369,7 @@ detectVersion() {
local -a selection_order=()
local result="" index=""
getVersions "$xml" versions bases groups image_indexes || return 1
getVersions "$xml" versions bases groups image_indexes || return
if [ "${#versions[@]}" -eq 0 ]; then
printf '%s\n%s\n' "$result" "$index"
@@ -924,7 +924,6 @@ detectReactOS() {
findIsoImage() {
local iso="$1"
local path
# Prefer install.wim when both payload forms are present.
@@ -1060,15 +1059,7 @@ readIsoImageInfo() {
result=$(udfread range --ignore-case "$iso" "$image" "$xml_offset" "$xml_size" \
2>/dev/null | iconv -f UTF-16LE -t UTF-8 2>/dev/null
) || {
local rc=$?
if (( rc >= 129 )); then
exit "$rc"
fi
return 1
}
) || return
[ -n "$result" ] || return 1
@@ -1209,15 +1200,9 @@ readImageInfo() {
local wim="$1"
local result=""
result=$(wimlib-imagex info --xml "$wim" | iconv -f UTF-16LE -t UTF-8) || {
local rc=$?
if (( rc >= 129 )); then
exit "$rc"
fi
if ! result=$(wimlib-imagex info --xml "$wim" | iconv -f UTF-16LE -t UTF-8); then
result=""
}
fi
if [ -z "$result" ]; then
error "Failed to read Windows image information!"
@@ -1349,10 +1334,10 @@ detectImageInfo() {
checkPlatform "$image_info" || exit 67
suggested=$(getSuggestion) || return 1
suggested=$(getSuggestion) || return
local output
output=$(detectVersion "$image_info" "$suggested") || return 1
output=$(detectVersion "$image_info" "$suggested") || return
local -a detected=()
mapfile -t detected <<< "$output"
@@ -1360,19 +1345,19 @@ detectImageInfo() {
DETECTED="${detected[0]:-}"
index="${detected[1]:-}"
validateEdition || return 1
validateEdition || return
if [ -z "$DETECTED" ]; then
unknownImage || return 1
unknownImage || return
return 0
fi
detectLanguage "$image_info" "$index" || return 1
detectLanguage "$image_info" "$index" || return
desc=$(describeImage) || return 1
desc=$(describeImage) || return
info "Detected: $desc"
configureImage "$index" "$desc" || return 1
configureImage "$index" "$desc" || return
return 0
}
@@ -1381,18 +1366,14 @@ detectIsoImage() {
local iso="$1"
local image header image_info rc
local image header image_info
# Return 1 only when no directly inspectable WIM/ESD payload is available so
# the caller may extract the media. Metadata parsing/configuration errors use 2.
image=$(findIsoImage "$iso") || return 1
header=$(readWimHeader "$iso" "$image") || return 2
image_info=$(readIsoImageInfo "$iso" "$image" "$header") || {
rc=$?
(( rc >= 129 )) && return "$rc"
return 2
}
image_info=$(readIsoImageInfo "$iso" "$image" "$header") || return 2
info "Detecting version from ISO image..."
detectImageInfo "$image_info" || return 2
@@ -1471,11 +1452,12 @@ extractESD() {
return 1
fi
if ! xml=$(wimlib-imagex info "$iso" --xml 2>/dev/null |
iconv -f UTF-16LE -t UTF-8 2>/dev/null); then
xml=$(wimlib-imagex info "$iso" --xml 2>/dev/null |
iconv -f UTF-16LE -t UTF-8 2>/dev/null) || {
ret=$?
error "Cannot read ESD file information!"
return 1
fi
return "$ret"
}
# Microsoft download ESDs use images 1-3 for setup media, WinPE, and Windows
# Setup; images 4 and higher contain installable editions. Read all metadata
@@ -1531,7 +1513,7 @@ extractESD() {
# installation media. Peak additional usage consists of the extracted setup
# files and boot.wim, plus the final ISO containing those files and the ESD.
local freeSpace=$(( size + 2 * (bootSize + wimSize) + spacePad ))
checkFreeSpace "$dir" "$freeSpace" || return 1
checkFreeSpace "$dir" "$freeSpace" || return
/run/progress.sh "$dir" "$bootSize" "$msg ([P])..." &
@@ -1540,7 +1522,7 @@ extractESD() {
ret=$?
fKill "progress.sh"
error "Extracting $desc bootdisk failed ($ret)"
return 1
return "$ret"
}
fKill "progress.sh"
@@ -1559,7 +1541,7 @@ extractESD() {
ret=$?
fKill "progress.sh"
error "Adding WinPE failed ($ret)"
return 1
return "$ret"
}
fKill "progress.sh"
@@ -1575,7 +1557,7 @@ extractESD() {
ret=$?
fKill "progress.sh"
error "Adding Windows Setup failed ($ret)"
return 1
return "$ret"
}
fKill "progress.sh"
@@ -1602,9 +1584,9 @@ extractESD() {
return 1
fi
checkPlatform "$xml" || return 1
checkPlatform "$xml" || return
output=$(detectVersion "$installXml") || return 1
output=$(detectVersion "$installXml") || return
mapfile -t detected <<< "$output"
index="${detected[1]:-}"
@@ -1665,20 +1647,22 @@ extractESD() {
(( image == index )) && continue
if ! wimlib-imagex delete "$installWim" "$image" --soft --quiet; then
wimlib-imagex delete "$installWim" "$image" --soft --quiet || {
ret=$?
fKill "progress.sh"
error "Failed to remove image $image from install.esd!"
return 1
fi
return "$ret"
}
done
if ! result=$(wimlib-imagex info "$installWim" --xml 2>/dev/null |
iconv -f UTF-16LE -t UTF-8 2>/dev/null); then
result=$(wimlib-imagex info "$installWim" --xml 2>/dev/null |
iconv -f UTF-16LE -t UTF-8 2>/dev/null) || {
ret=$?
fKill "progress.sh"
error "Cannot verify the prepared install.esd file!"
return 1
fi
return "$ret"
}
if ! metadata=$(xmlstarlet sel -t \
-v 'count(/WIM/IMAGE)' -n \
@@ -2009,7 +1993,7 @@ buildImage() {
local cat="BOOT.CAT"
local log="/run/shm/iso.log"
local base size desc failed=""
local base size desc rc=0
if [ -f "$BOOT" ]; then
error "File $BOOT does already exist?!" && return 1
@@ -2118,15 +2102,14 @@ buildImage() {
fi
if ! genisoimage "${args[@]}" -quiet "$dir" 2> "$log"; then
failed="y"
fi
genisoimage "${args[@]}" -quiet "$dir" 2> "$log" || rc=$?
fKill "progress.sh"
if [ -n "$failed" ]; then
if (( rc != 0 )); then
[ -s "$log" ] && echo "$(<"$log")"
error "Failed to build image!" && return 1
error "Failed to build image!"
return "$rc"
fi
local err=""
@@ -2139,7 +2122,7 @@ buildImage() {
echo "$err"
fi
mv -f "$out" "$BOOT" || return 1
mv -f "$out" "$BOOT" || return
if ! setOwner "$BOOT"; then
warn "Failed to set the owner for \"$BOOT\" !"
+27 -59
View File
@@ -43,8 +43,6 @@ selectWindowsImage() {
local dir="$2"
local boot="$3"
local detect_rc=0
# Known versions already provide the required image metadata.
if resolveImage "$VERSION"; then
@@ -67,20 +65,10 @@ selectWindowsImage() {
fi
# Inspect unknown media directly before falling back to extraction.
detectIsoImage "$iso" || detect_rc=$?
detectIsoImage "$iso" && return 0
if (( detect_rc == 0 )); then
return 0
fi
if (( detect_rc >= 129 )); then
return "$detect_rc"
fi
# Only code 1 indicates that extraction may recover detection.
if (( detect_rc != 1 )); then
return 76
fi
local rc=$?
(( rc == 1 )) || return 76
if ! extractImage "$iso" "$dir" "$VERSION"; then
removeImage "$iso" || :
@@ -88,21 +76,11 @@ selectWindowsImage() {
fi
extracted=1
detect_rc=0
detectImage "$dir" || detect_rc=$?
detectImage "$dir" && return 0
if (( detect_rc == 0 )); then
return 0
fi
if (( detect_rc >= 129 )); then
return "$detect_rc"
fi
if (( detect_rc != 1 )); then
return 76
fi
rc=$?
(( rc == 1 )) || return 76
skipUnattended "$dir" "$iso" "$boot" || return 76
@@ -189,10 +167,10 @@ prepareWindowsImage() {
bootWindows() {
restoreMachineState || return 1
restoreBootMode || return 1
restoreMachine || return 1
reserveSambaPorts || return 1
restoreMachineState || return
restoreBootMode || return
restoreMachine || return
reserveSambaPorts || return
return 0
}
@@ -752,9 +730,8 @@ getArchiveSize() {
listing=$(7z l -slt "$file" 2>/dev/null) || {
rc=$?
(( rc >= 129 )) && exit "$rc"
error "Failed to read archive information: $file"
return 1
return "$rc"
}
while IFS= read -r line; do
@@ -797,11 +774,7 @@ extractImage() {
fi
if [[ "${iso,,}" == *".esd" ]]; then
extractESD "$iso" "$dir" "$version" "$desc" || {
rc=$?
(( rc >= 129 )) && exit "$rc"
return 1
}
extractESD "$iso" "$dir" "$version" "$desc" || return
return 0
fi
@@ -833,7 +806,7 @@ extractImage() {
required="$size"
if enabled "${UNPACK:-}"; then
getArchiveSize "$iso" archiveSize || return 1
getArchiveSize "$iso" archiveSize || return
required="$archiveSize"
fi
@@ -849,9 +822,8 @@ extractImage() {
7z x "$iso" -o"$target" > /dev/null || {
rc=$?
fKill "progress.sh"
(( rc >= 129 )) && exit "$rc"
error "Failed to extract ISO file: $iso"
return 1
return "$rc"
}
fKill "progress.sh"
@@ -897,9 +869,8 @@ extractImage() {
7z x "$iso" -o"$dir" > /dev/null || {
rc=$?
(( rc >= 129 )) && exit "$rc"
error "Failed to extract nested ISO file: $iso"
return 1
return "$rc"
}
LABEL=$(isoinfo -d -i "$iso" | sed -n 's/Volume id: //p') || LABEL=""
@@ -915,32 +886,29 @@ detectImage() {
local dir="$1"
local desc detect_rc=0
local desc rc
info "Detecting version from ISO image..."
# Marker-based legacy and ReactOS detection must run before looking for a WIM.
detectLegacy "$dir" || detect_rc=$?
if (( detect_rc == 0 )); then
if detectLegacy "$dir"; then
desc=$(printEdition "$DETECTED" "$DETECTED" "Y") || return 2
info "Detected: $desc"
return 0
else
rc=$?
(( rc == 1 )) || return "$rc"
fi
(( detect_rc == 1 )) || return "$detect_rc"
detect_rc=0
detectReactOS "$dir" || detect_rc=$?
if (( detect_rc == 0 )); then
if detectReactOS "$dir"; then
desc=$(printEdition "$DETECTED" "$DETECTED" "Y") || return 2
info "Detected: $desc"
return 0
else
rc=$?
(( rc == 1 )) || return "$rc"
fi
(( detect_rc == 1 )) || return "$detect_rc"
local wim
wim=$(findImage "$dir") || return $?
@@ -1370,11 +1338,11 @@ checkMemory() {
local id="$1"
local required name
required=$(getRequiredMemory "$id") || return 1
required=$(getRequiredMemory "$id") || return
RAM_MINIMUM="$required"
name=$(printVersion "$id" "") || return 1
checkMemoryRequirement "$name" || return 1
name=$(printVersion "$id" "") || return
checkMemoryRequirement "$name" || return
return 0
}
+99 -105
View File
@@ -126,11 +126,7 @@ downloadWindowsLink() {
--output /dev/null \
--header "Accept:" \
--max-filesize 100K \
-- "$vlsUrl" || {
local rc=$?
(( rc >= 129 )) && exit "$rc"
return 1
}
-- "$vlsUrl" || return
# Complete Microsoft's ov-df challenge by retrieving a token and timing
# value, then returning both with the current timestamp.
@@ -143,11 +139,7 @@ downloadWindowsLink() {
ovData=$(curlRequest "Microsoft" "$agent" \
--header "Accept:" \
--max-filesize 1M \
-- "$ovUrl") || {
local rc=$?
(( rc >= 129 )) && exit "$rc"
return 1
}
-- "$ovUrl") || return
if [[ $ovData =~ [\?\&]w=([A-Fa-f0-9]+) ]]; then
ovToken="${BASH_REMATCH[1]}"
@@ -175,11 +167,7 @@ downloadWindowsLink() {
--output /dev/null \
--header "Accept:" \
--max-filesize 100K \
-- "$ovUrl" || {
local rc=$?
(( rc >= 129 )) && exit "$rc"
return 1
}
-- "$ovUrl" || return
enabled "$DEBUG" && echo -n "Getting language SKU ID: "
@@ -189,17 +177,13 @@ downloadWindowsLink() {
--referer "$url" \
--header "Accept:" \
--max-filesize 100K \
-- "$skuUrl") || {
local rc=$?
(( rc >= 129 )) && exit "$rc"
return 1
}
-- "$skuUrl") || return
# Guard jq under errexit so malformed API data can be handled as a normal
# missing-result error. The same pattern is reused for the link response.
{ skuId=$(printf '%s\n' "$skuJson" | jq --arg LANG "$language" -r 'first(.Skus[]? | select(.Language == $LANG) | .Id) // empty') 2>/dev/null; local rc=$?; } || :
# Let jq parsing failures propagate so malformed API data is not mistaken
# for a normal missing-result response. The same applies to the link data.
skuId=$(printf '%s\n' "$skuJson" | jq --arg LANG "$language" -r 'first(.Skus[]? | select(.Language == $LANG) | .Id) // empty') 2>/dev/null || return
if [ -z "$skuId" ] || [[ "${skuId,,}" == "null" ]] || (( rc != 0 )); then
if [ -z "$skuId" ] || [[ "${skuId,,}" == "null" ]]; then
language=$(getLanguage "$lang" "desc")
error "No download in the $language language available for $desc!"
return 1
@@ -217,11 +201,7 @@ downloadWindowsLink() {
--referer "$url" \
--header "Accept:" \
--max-filesize 100K \
-- "$linkUrl") || {
local rc=$?
(( rc >= 129 )) && exit "$rc"
return 1
}
-- "$linkUrl") || return
if ! [ "$linkJson" ]; then
error "Microsoft servers gave us an empty response to our request for an automated download."
@@ -238,9 +218,9 @@ downloadWindowsLink() {
return 1
fi
{ link=$(printf '%s\n' "$linkJson" | jq --argjson TYPE "$type" -r 'first(.ProductDownloadOptions[]? | select(.DownloadType == $TYPE) | .Uri) // empty') 2>/dev/null; rc=$?; } || :
link=$(printf '%s\n' "$linkJson" | jq --argjson TYPE "$type" -r 'first(.ProductDownloadOptions[]? | select(.DownloadType == $TYPE) | .Uri) // empty') 2>/dev/null || return
if [ -z "$link" ] || [[ "${link,,}" == "null" ]] || (( rc != 0 )); then
if [ -z "$link" ] || [[ "${link,,}" == "null" ]]; then
error "Microsoft server gave us no download link to our request for an automated download!"
info "Response: $linkJson"
return 1
@@ -256,7 +236,7 @@ downloadWindows() {
local lang="$2"
local desc="$3"
local agent language page
local agent language page rc
local productId type winVer
agent=$(getAgent)
@@ -287,9 +267,12 @@ downloadWindows() {
if downloadWindowsLink "$productId" "$url" "$agent" "$language" "$lang" "$desc" "$type"; then
return 0
else
rc=$?
(( rc == 1 )) || return "$rc"
fi
sleep 1
sleep 1 || return
# Product edition IDs can change. If the configured ID fails, recover the
# current value from Microsoft's public download page and retry once.
@@ -300,11 +283,7 @@ downloadWindows() {
page=$(curlRequest "Microsoft" "$agent" \
--header "Accept:" \
--max-filesize 1M \
-- "$url") || {
local rc=$?
(( rc >= 129 )) && exit "$rc"
return 1
}
-- "$url") || return
enabled "$DEBUG" && echo -n "Getting Product edition ID: "
productId=$(printf '%s' "$page" |
@@ -312,7 +291,7 @@ downloadWindows() {
grep -Eio "<option[^>]*value=[\"'][0-9]+[\"'][^>]*>[[:space:]]*Windows[^<]*" |
sed -nE "s/.*value=[\"']([0-9]+)[\"'].*/\1/p" |
sed -n '1p' |
cut -c 1-16 || true)
cut -c 1-16) || return
enabled "$DEBUG" && echo "$productId"
if [ -z "$productId" ]; then
@@ -320,9 +299,7 @@ downloadWindows() {
return 1
fi
if ! downloadWindowsLink "$productId" "$url" "$agent" "$language" "$lang" "$desc" "$type"; then
return 1
fi
downloadWindowsLink "$productId" "$url" "$agent" "$language" "$lang" "$desc" "$type" || return
return 0
}
@@ -334,12 +311,9 @@ downloadWindowsEval() {
local desc="$3"
local compare compare_name link_name
local agent culture language type winVer
local agent culture language type winVer rc
case "${id,,}" in
"win10${PLATFORM,,}-enterprise-eval" )
type="enterprise"
winVer="windows-10-enterprise" ;;
"win11${PLATFORM,,}-enterprise-eval" )
type="enterprise"
winVer="windows-11-enterprise" ;;
@@ -385,11 +359,7 @@ downloadWindowsEval() {
page=$(curlRequest "Microsoft" "$agent" \
--location \
--max-filesize 1M \
-- "$url") || {
local rc=$?
(( rc >= 129 )) && exit "$rc"
return 1
}
-- "$url") || return
if ! [ "$page" ]; then
error "Evaluation Center download page gave us an empty response"
@@ -438,8 +408,8 @@ downloadWindowsEval() {
--write-out "%{redirect_url}" \
--head \
-- "$candidate") || {
local rc=$?
(( rc >= 129 )) && exit "$rc"
rc=$?
(( rc == 1 )) || return "$rc"
continue
}
@@ -531,11 +501,7 @@ downloadWindowsEval() {
--output /dev/null \
--write-out "%{url_effective}" \
--head \
-- "$link") || {
local rc=$?
(( rc >= 129 )) && exit "$rc"
return 1
}
-- "$link") || return
local lower="${link,,}"
local separator='(^|[[:space:]_./-])'
@@ -640,7 +606,7 @@ downloadWindowsLtsc() {
local lang="$2"
local desc="$3"
local alternate alternate_desc
local alternate alternate_desc rc
case "${id,,}" in
"win11${PLATFORM,,}-enterprise-iot-eval" )
@@ -657,19 +623,21 @@ downloadWindowsLtsc() {
if downloadWindowsEval "$id" "$lang" "$desc" > /dev/null 2>&1; then
MIDO_SOURCE="$id"
return 0
else
rc=$?
(( rc == 1 )) || return "$rc"
fi
alternate_desc=$(printEdition "$alternate" "$alternate" "Y")
info "Primary download source failed, trying $alternate_desc instead..."
if downloadWindowsEval "$alternate" "$lang" "$alternate_desc"; then
downloadWindowsEval "$alternate" "$lang" "$alternate_desc" || return
MIDO_SOURCE="$alternate"
warn "the requested $desc was unavailable, using $alternate_desc instead."
return 0
fi
return 1
return 0
}
getWindows() {
@@ -679,7 +647,7 @@ getWindows() {
local desc="$3"
local web_desc="$4"
local language edition
local language edition rc
MIDO_SOURCE=""
MIDO_STATIC="N"
@@ -727,19 +695,29 @@ getWindows() {
if downloadWindows "$version" "$lang" "$edition"; then
MIDO_SOURCE="$version"
return 0
else
rc=$?
(( rc == 1 )) || return "$rc"
fi ;;
"win11${PLATFORM,,}-enterprise-iot-eval" | \
"win11${PLATFORM,,}-enterprise-ltsc-eval" )
downloadWindowsLtsc "$version" "$lang" "$edition" && return 0 ;;
if downloadWindowsLtsc "$version" "$lang" "$edition"; then
return 0
else
rc=$?
(( rc == 1 )) || return "$rc"
fi ;;
"win10${PLATFORM,,}-enterprise-eval" | \
"win11${PLATFORM,,}-enterprise"* )
if downloadWindowsEval "$version" "$lang" "$edition"; then
MIDO_SOURCE="$version"
return 0
else
rc=$?
(( rc == 1 )) || return "$rc"
fi ;;
"win2025-eval" | "win2022-eval" | "win2019-eval" | \
@@ -748,6 +726,9 @@ getWindows() {
if downloadWindowsEval "$version" "$lang" "$edition"; then
MIDO_SOURCE="$version"
return 0
else
rc=$?
(( rc == 1 )) || return "$rc"
fi ;;
"win2008r2"*| "win81${PLATFORM,,}"* | "win10${PLATFORM,,}-enterprise"* ) ;;
@@ -1077,7 +1058,10 @@ getESD() {
local msg="Downloading ESD catalog..."
info "$msg" && html "$msg"
rm -rf "$dir"
if ! rm -rf "$dir"; then
error "Failed to remove directory \"$dir\" !"
return 1
fi
if ! makeDir "$dir"; then
error "Failed to create directory \"$dir\" !"
@@ -1118,7 +1102,7 @@ getESD() {
rm -f "$log"
if (( rc >= 129 )); then
exit "$rc"
return "$rc"
fi
return 1
@@ -1160,8 +1144,7 @@ getESD() {
validateESDCatalog "$dir/$xmlFile" "$provider" || return 1
fi
if ! parseESD \
"$dir/$xmlFile" "$version" "$lang" "$desc" "$edition" "$culture"; then
if ! parseESD "$dir/$xmlFile" "$version" "$lang" "$desc" "$edition" "$culture"; then
return 1
fi
@@ -1222,26 +1205,16 @@ verifyFile() {
hash=$(sha1sum "$iso" | cut -f1 -d' ') || {
local rc=$?
if (( rc >= 129 )); then
exit "$rc"
fi
error "Failed to calculate SHA1 checksum for $iso!"
return 1
return "$rc"
}
else
hash=$(sha256sum "$iso" | cut -f1 -d' ') || {
local rc=$?
if (( rc >= 129 )); then
exit "$rc"
fi
error "Failed to calculate SHA256 checksum for $iso!"
return 1
return "$rc"
}
fi
@@ -1315,7 +1288,7 @@ tryDownload() {
minimum="10485760"
fi
if downloadRetry \
downloadRetry \
"$iso" \
"${CONNECTIONS:-1}" \
"$seconds" \
@@ -1325,17 +1298,7 @@ tryDownload() {
"$url" \
"$size" \
"$desc" \
"$web_desc"; then
local rc=0
else
local rc=$?
fi
if (( rc >= 129 )); then
exit "$rc"
fi
(( rc == 0 )) || return "$rc"
"$web_desc" || return
# The shared helper already inspected the file, so this should
# only fail if the downloaded file was removed unexpectedly afterward.
@@ -1345,12 +1308,15 @@ tryDownload() {
fi
# Status 2 means the completed download failed deterministic validation.
if ! verifyFile "$iso" "$size" "$total" "$sum"; then
verifyFile "$iso" "$size" "$total" "$sum" || {
local rc=$?
(( rc == 1 )) || return "$rc"
if ! rm -f -- "$iso" "$iso.aria2"; then
warn "failed to remove invalid download \"$iso\"!"
fi
return 2
fi
}
# Extract the .iso from the compressed archive if needed.
isCompressed "$url" && UNPACK="Y"
@@ -1379,7 +1345,7 @@ fallbackEnglish() {
# still locate the same image, but use English installation media.
LANGUAGE="en"
removeImage "$iso" || return 1
removeImage "$iso" || return
downloadImage "$iso" "$version" "$LANGUAGE"
}
@@ -1410,7 +1376,7 @@ downloadImage() {
local detected="$DETECTED"
local requested="$version" switched=""
local tried="n" success="n" seconds="5"
local i url sum size base language desc web_desc metadata
local i url sum size base language desc web_desc metadata rc
if [[ "${version,,}" == "http"* ]]; then
@@ -1418,7 +1384,7 @@ downloadImage() {
desc=$(fromFile "$base")
web_desc="$desc"
tryDownload "$iso" "$version" "" "" "$desc" "$seconds" "$web_desc" || return 1
tryDownload "$iso" "$version" "" "" "$desc" "$seconds" "$web_desc" || return
return 0
fi
@@ -1437,7 +1403,7 @@ downloadImage() {
web_desc=$(printEdition "$version" "$web_desc")
desc+=" in $language"
fallbackEnglish "$iso" "$version" "$lang" "$desc" || return 1
fallbackEnglish "$iso" "$version" "$lang" "$desc" || return
return 0
fi
@@ -1455,8 +1421,17 @@ downloadImage() {
if getWindows "$version" "$lang" "$desc" "$web_desc"; then
success="y"
else
delay "$seconds"
getWindows "$version" "$lang" "$desc" "$web_desc" && success="y"
rc=$?
(( rc == 1 )) || return "$rc"
delay "$seconds" || return
if getWindows "$version" "$lang" "$desc" "$web_desc"; then
success="y"
else
rc=$?
(( rc == 1 )) || return "$rc"
fi
fi
if [[ "$success" == "y" ]]; then
@@ -1483,6 +1458,9 @@ downloadImage() {
# Commit the candidate only after the image was downloaded and verified.
DETECTED="$detected"
return 0
else
rc=$?
(( rc == 1 || rc == 2 )) || return "$rc"
fi
fi
@@ -1520,7 +1498,15 @@ downloadImage() {
if getESD "$TMP/esd" "$version" "$lang" "$desc"; then
success="y"
else
getESD "$TMP/esd" "$version" "$lang" "$desc" "wor" && success="y"
rc=$?
(( rc == 1 )) || return "$rc"
if getESD "$TMP/esd" "$version" "$lang" "$desc" "wor"; then
success="y"
else
rc=$?
(( rc == 1 )) || return "$rc"
fi
fi
if [[ "$success" == "y" ]]; then
@@ -1531,6 +1517,9 @@ downloadImage() {
if tryDownload "$ISO" "$ESD" "$ESD_SUM" "$ESD_SIZE" "$desc" "$seconds" "$web_desc"; then
return 0
else
rc=$?
(( rc == 1 || rc == 2 )) || return "$rc"
fi
ISO="$iso"
@@ -1552,14 +1541,19 @@ downloadImage() {
size=$(getSize "$i" "$version" "$lang")
sum=$(getHash "$i" "$version" "$lang")
tryDownload "$iso" "$url" "$sum" "$size" "$desc" "$seconds" "$web_desc" && return 0
if tryDownload "$iso" "$url" "$sum" "$size" "$desc" "$seconds" "$web_desc"; then
return 0
else
rc=$?
(( rc == 1 || rc == 2 )) || return "$rc"
fi
fi
done
if [[ "${lang,,}" != "en" && "${lang,,}" != "en-"* ]]; then
fallbackEnglish "$iso" "$requested" "$lang" "$desc" || return 1
fallbackEnglish "$iso" "$requested" "$lang" "$desc" || return
return 0
fi