Browse Source

feat: Set user agent for downloads (#1209)

Kroese 2 months ago
parent
commit
87f3fd119b
1 changed files with 5 additions and 4 deletions
  1. 5 4
      src/mido.sh

+ 5 - 4
src/mido.sh

@@ -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