Better error handling for wget show-progress

This commit is contained in:
Alex Malinovich 2016-11-20 19:32:37 -08:00 committed by Henric Andersson
commit 144989e9c3

View file

@ -322,7 +322,11 @@ if [ "${SAVECONFIG}" = "yes" ]; then
fi fi
if [ "${SHOWPROGRESS}" = "yes" ]; then if [ "${SHOWPROGRESS}" = "yes" ]; then
WGETOPTIONS="--show-progress" if ! wget --show-progress -V &>/dev/null; then
warn "Your wget is too old to support --show-progress, ignoring"
else
WGETOPTIONS="--show-progress"
fi
fi fi
if [ "${IGNOREAUTOUPDATE}" = "yes" ]; then if [ "${IGNOREAUTOUPDATE}" = "yes" ]; then
@ -613,12 +617,6 @@ if [ "${SKIP_DOWNLOAD}" = "no" ]; then
info "Downloading release \"${FILENAME}\"" info "Downloading release \"${FILENAME}\""
wget ${WGETOPTIONS} -o "${FILE_WGETLOG}" --load-cookies "${FILE_KAKA}" --save-cookies "${FILE_KAKA}" --keep-session-cookies "${DOWNLOAD}" -O "${DOWNLOADDIR}/${FILENAME}" 2>&1 wget ${WGETOPTIONS} -o "${FILE_WGETLOG}" --load-cookies "${FILE_KAKA}" --save-cookies "${FILE_KAKA}" --keep-session-cookies "${DOWNLOAD}" -O "${DOWNLOADDIR}/${FILENAME}" 2>&1
CODE=$? CODE=$?
if [ ${CODE} -eq 2 ]; then
error "Your wget is too old to support --show-progress"
info "Trying to download release \"${FILENAME}\" again"
wget -o "${FILE_WGETLOG}" --load-cookies "${FILE_KAKA}" --save-cookies "${FILE_KAKA}" --keep-session-cookies "${DOWNLOAD}" -O "${DOWNLOADDIR}/${FILENAME}" 2>&1
CODE=$?
fi
if [ ${CODE} -ne 0 ]; then if [ ${CODE} -ne 0 ]; then
error "Download failed with code ${CODE}:" error "Download failed with code ${CODE}:"