From 81f0506bf7e3807f5b359a6cee6e696ccebd6cd7 Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Fri, 19 Apr 2024 16:32:14 +0100 Subject: [PATCH] fix: web_get() now tests for redirections using curl Mostly this fixes downloads from sourceforge, but should make curl downloads more reliable in general --- quickget | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/quickget b/quickget index 1b571a9..f50f4f2 100755 --- a/quickget +++ b/quickget @@ -1490,6 +1490,13 @@ function web_get() { fi if command -v curl &>/dev/null; then + # Check for URL redirections + # Output to nonexistent directory so the download fails fast + local REDIRECT_URL=$(curl --silent --location --fail "${URL}" --write-out %{url_effective} --output /var/cache/${RANDOM}/${RANDOM}) + if [ "${REDIRECT_URL}" != "${URL}" ]; then + echo "Redirected to ${REDIRECT_URL}" + URL="${REDIRECT_URL}" + fi if ! curl --progress-bar --location --output "${DIR}/${FILE}" --continue-at - --user-agent "${USER_AGENT}" "${HEADERS[@]}" -- "${URL}"; then echo "ERROR! Failed to download ${URL} with curl." echo " Try deleting '${DIR}/${FILE}' running 'quickget' again."