Skip to content

Commit 75852ab

Browse files
authored
fix(core): unhandled curl fail (#4159)
1 parent 4c717c5 commit 75852ab

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

lgsm/functions/core_dl.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -383,17 +383,21 @@ fn_fetch_file() {
383383
fi
384384
# Trap will remove part downloaded files if canceled.
385385
trap fn_fetch_trap INT
386-
# Larger files show a progress bar.
387-
if [ "${local_filename##*.}" == "bz2" ] || [ "${local_filename##*.}" == "gz" ] || [ "${local_filename##*.}" == "zip" ] || [ "${local_filename##*.}" == "jar" ] || [ "${local_filename##*.}" == "xz" ]; then
388-
echo -e "downloading ${local_filename}..."
389-
fn_sleep_time
390-
curlcmd=$(curl --connect-timeout 10 --progress-bar --fail -L -o "${local_filedir}/${local_filename}" "${fileurl}")
391-
local exitcode=$?
386+
curlcmd=(curl --connect-timeout 10 --fail -L -o "${local_filedir}/${local_filename}" --retry 2)
387+
388+
# if is large file show progress, else be silent
389+
local exitcode=""
390+
large_files=("bz2" "gz" "zip" "jar" "xz")
391+
if grep -qE "(^|\s)${local_filename##*.}(\s|$)" <<< "${large_files[@]}"; then
392392
echo -en "downloading ${local_filename}..."
393+
fn_sleep_time
394+
echo -en "\033[1K"
395+
"${curlcmd[@]}" --progress-bar "${fileurl}" 2>&1
396+
exitcode="$?"
393397
else
394-
curlcmd=$(curl --connect-timeout 10 -s --fail -L -o "${local_filedir}/${local_filename}" "${fileurl}")
395-
local exitcode=$?
396398
echo -en "fetching ${fileurl_name} ${local_filename}...\c"
399+
"${curlcmd[@]}" --silent --show-error "${fileurl}" 2>&1
400+
exitcode="$?"
397401
fi
398402

399403
# Download will fail if downloads a html file.

0 commit comments

Comments
 (0)