Skip to content

Commit 87f3fd1

Browse files
authored
feat: Set user agent for downloads (#1209)
1 parent 2bacbac commit 87f3fd1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/mido.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,10 @@ downloadFile() {
530530
local lang="$5"
531531
local desc="$6"
532532
local msg="Downloading $desc"
533-
local rc total total_gb progress domain dots space folder
533+
local rc total total_gb progress domain dots agent space folder
534534

535535
rm -f "$iso"
536+
agent=$(get_agent)
536537

537538
if [ -n "$size" ] && [[ "$size" != "0" ]]; then
538539
folder=$(dirname -- "$iso")
@@ -561,15 +562,15 @@ downloadFile() {
561562

562563
info "$msg..."
563564

564-
{ wget "$url" -O "$iso" -q --timeout=30 --no-http-keep-alive --show-progress "$progress"; rc=$?; } || :
565+
{ wget "$url" -O "$iso" -q --timeout=30 --no-http-keep-alive --user-agent "$agent" --show-progress "$progress"; rc=$?; } || :
565566

566567
fKill "progress.sh"
567568

568569
if (( rc == 0 )) && [ -f "$iso" ]; then
569570
total=$(stat -c%s "$iso")
570571
total_gb=$(formatBytes "$total")
571572
if [ "$total" -lt 100000000 ]; then
572-
error "Invalid download link: $url (is only $total_gb ?). Please report this at $SUPPORT/issues." && return 1
573+
error "Invalid download link: $url (is only $total_gb ?). Please report this at $SUPPORT/issues" && return 1
573574
fi
574575
verifyFile "$iso" "$size" "$total" "$sum" || return 1
575576
isCompressed "$url" && UNPACK="Y"
@@ -579,7 +580,7 @@ downloadFile() {
579580
msg="Failed to download $url"
580581
(( rc == 3 )) && error "$msg , cannot write file (disk full?)" && return 1
581582
(( rc == 4 )) && error "$msg , network failure!" && return 1
582-
(( rc == 8 )) && error "$msg , server issued an error response! Please report this at $SUPPORT/issues." && return 1
583+
(( rc == 8 )) && error "$msg , server issued an error response! Please report this at $SUPPORT/issues" && return 1
583584

584585
error "$msg , reason: $rc"
585586
return 1

0 commit comments

Comments
 (0)