mirror of
https://github.com/dockur/windows.git
synced 2024-09-29 22:13:47 +00:00
feat: Refactor download code
This commit is contained in:
parent
355455cf13
commit
d664bd0cf7
1 changed files with 0 additions and 62 deletions
|
@ -209,68 +209,6 @@ detectCustom() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadImage() {
|
|
||||||
|
|
||||||
local iso="$1"
|
|
||||||
local version="$2"
|
|
||||||
local tried="n"
|
|
||||||
local url sum size base desc
|
|
||||||
|
|
||||||
if [[ "${version,,}" == "http"* ]]; then
|
|
||||||
base=$(basename "$iso")
|
|
||||||
desc=$(fromFile "$base")
|
|
||||||
downloadFile "$iso" "$version" "" "" "$desc" && return 0
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! validVersion "$version"; then
|
|
||||||
error "Invalid VERSION specified, value \"$version\" is not recognized!" && return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
desc=$(printVersion "$version" "")
|
|
||||||
|
|
||||||
if isMido "$version"; then
|
|
||||||
tried="y"
|
|
||||||
doMido "$iso" "$version" "$desc" && return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
switchEdition "$version"
|
|
||||||
|
|
||||||
if isESD "$version"; then
|
|
||||||
|
|
||||||
if [[ "$tried" != "n" ]]; then
|
|
||||||
info "Failed to download $desc using Mido, will try a diferent method now..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
tried="y"
|
|
||||||
|
|
||||||
if getESD "$TMP/esd" "$version"; then
|
|
||||||
ISO="${ISO%.*}.esd"
|
|
||||||
downloadFile "$ISO" "$ESD" "$ESD_SUM" "$ESD_SIZE" "$desc" && return 0
|
|
||||||
ISO="$iso"
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
for ((i=1;i<=MIRRORS;i++)); do
|
|
||||||
|
|
||||||
url=$(getLink "$i" "$version")
|
|
||||||
|
|
||||||
if [ -n "$url" ]; then
|
|
||||||
if [[ "$tried" != "n" ]]; then
|
|
||||||
info "Failed to download $desc, will try another mirror now..."
|
|
||||||
fi
|
|
||||||
tried="y"
|
|
||||||
size=$(getSize "$i" "$version")
|
|
||||||
sum=$(getHash "$i" "$version")
|
|
||||||
downloadFile "$iso" "$url" "$sum" "$size" "$desc" && return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
removeDownload() {
|
removeDownload() {
|
||||||
|
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
|
|
Loading…
Reference in a new issue