Skip to content

Commit a8f43c2

Browse files
committed
fix: updating http_download_wget() to handle more failure scenarios
1 parent cdf68aa commit a8f43c2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

install.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,19 @@ http_download_wget() {
310310
local_file=$1
311311
source_url=$2
312312
header=$3
313+
local wget_output
314+
local code
313315
if [ -z "$header" ]; then
314-
code=$(wget --server-response --quiet -O "$local_file" "$source_url" 2>&1 | awk '/^ HTTP/{print $2}' | tail -n1)
316+
wget_output=$(wget --server-response --quiet -O "$local_file" "$source_url" 2>&1)
315317
else
316-
code=$(wget --server-response --quiet --header "$header" -O "$local_file" "$source_url" 2>&1 | awk '/^ HTTP/{print $2}' | tail -n1)
318+
wget_output=$(wget --server-response --quiet --header "$header" -O "$local_file" "$source_url" 2>&1)
317319
fi
320+
local wget_exit=$?
321+
if [ $wget_exit -ne 0 ]; then
322+
log_err "http_download_wget failed: wget exited with status $wget_exit"
323+
return 1
324+
fi
325+
code=$(echo "$wget_output" | awk '/^ HTTP/{print $2}' | tail -n1)
318326
if [ "$code" != "200" ]; then
319327
log_err "http_download_wget received HTTP status $code"
320328
return 1

0 commit comments

Comments
 (0)