feat: Set user agent for downloads (#1209)

This commit is contained in:
Kroese 2025-04-20 11:38:21 +02:00 committed by GitHub
parent 2bacbac1f9
commit 87f3fd119b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -530,9 +530,10 @@ downloadFile() {
local lang="$5" local lang="$5"
local desc="$6" local desc="$6"
local msg="Downloading $desc" local msg="Downloading $desc"
local rc total total_gb progress domain dots space folder local rc total total_gb progress domain dots agent space folder
rm -f "$iso" rm -f "$iso"
agent=$(get_agent)
if [ -n "$size" ] && [[ "$size" != "0" ]]; then if [ -n "$size" ] && [[ "$size" != "0" ]]; then
folder=$(dirname -- "$iso") folder=$(dirname -- "$iso")
@ -561,7 +562,7 @@ downloadFile() {
info "$msg..." info "$msg..."
{ wget "$url" -O "$iso" -q --timeout=30 --no-http-keep-alive --show-progress "$progress"; rc=$?; } || : { wget "$url" -O "$iso" -q --timeout=30 --no-http-keep-alive --user-agent "$agent" --show-progress "$progress"; rc=$?; } || :
fKill "progress.sh" fKill "progress.sh"
@ -569,7 +570,7 @@ downloadFile() {
total=$(stat -c%s "$iso") total=$(stat -c%s "$iso")
total_gb=$(formatBytes "$total") total_gb=$(formatBytes "$total")
if [ "$total" -lt 100000000 ]; then if [ "$total" -lt 100000000 ]; then
error "Invalid download link: $url (is only $total_gb ?). Please report this at $SUPPORT/issues." && return 1 error "Invalid download link: $url (is only $total_gb ?). Please report this at $SUPPORT/issues" && return 1
fi fi
verifyFile "$iso" "$size" "$total" "$sum" || return 1 verifyFile "$iso" "$size" "$total" "$sum" || return 1
isCompressed "$url" && UNPACK="Y" isCompressed "$url" && UNPACK="Y"
@ -579,7 +580,7 @@ downloadFile() {
msg="Failed to download $url" msg="Failed to download $url"
(( rc == 3 )) && error "$msg , cannot write file (disk full?)" && return 1 (( rc == 3 )) && error "$msg , cannot write file (disk full?)" && return 1
(( rc == 4 )) && error "$msg , network failure!" && return 1 (( rc == 4 )) && error "$msg , network failure!" && return 1
(( rc == 8 )) && error "$msg , server issued an error response! Please report this at $SUPPORT/issues." && return 1 (( rc == 8 )) && error "$msg , server issued an error response! Please report this at $SUPPORT/issues" && return 1
error "$msg , reason: $rc" error "$msg , reason: $rc"
return 1 return 1