Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip checksum when download file failed. #3079

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,24 +128,24 @@ nvm_download() {
if nvm_curl_use_compression; then
CURL_COMPRESSED_FLAG="--compressed"
fi
eval "curl -q --fail ${CURL_COMPRESSED_FLAG:-} ${CURL_HEADER_FLAG:-} $*"
eval "curl -q --fail -w %{http_code} ${CURL_COMPRESSED_FLAG:-} ${CURL_HEADER_FLAG:-} $*"
elif nvm_has "wget"; then
# Emulate curl with wget
ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
-e 's/--compressed //' \
-e 's/--fail //' \
-e 's/-L //' \
-e 's/-I /--server-response /' \
-e 's/-s /-q /' \
-e 's/-sS /-nv /' \
-e 's/-o /-O /' \
-e 's/-C - /-c /')
-e 's/--compressed //' \
-e 's/--fail //' \
-e 's/-L //' \
-e 's/-I /--server-response /' \
-e 's/-s /-q /' \
-e 's/-sS /-nv /' \
-e 's/-o /-O /' \
-e 's/-C - /-c /')

if [ -n "${NVM_AUTH_HEADER:-}" ]; then
ARGS="${ARGS} --header \"${NVM_AUTH_HEADER}\""
fi
# shellcheck disable=SC2086
eval wget $ARGS
eval wget -S $ARGS 2>&1 | grep '^ HTTP/' | awk '{print $2}'
fi
}

Expand Down Expand Up @@ -2434,12 +2434,18 @@ nvm_download_artifact() {
nvm_err "Removing the broken local cache..."
command rm -rf "${TARBALL}"
fi

nvm_err "Downloading ${TARBALL_URL}..."
nvm_download -L -C - "${PROGRESS_BAR}" "${TARBALL_URL}" -o "${TARBALL}" || (
local NVM_DOWNLOAD_RESULT
NVM_DOWNLOAD_RESULT=$(nvm_download -L -C - "${PROGRESS_BAR}" "${TARBALL_URL}" -o "${TARBALL}")
if [ "${NVM_DEBUG-}" = 1 ]; then
nvm_err "Download HTTP Status ${NVM_DOWNLOAD_RESULT}"
fi
if [ "${NVM_DOWNLOAD_RESULT}" != '200' ]; then
command rm -rf "${TARBALL}" "${tmpdir}"
nvm_err "Binary download from ${TARBALL_URL} failed, trying source."
return 4
)
fi

if nvm_grep '404 Not Found' "${TARBALL}" >/dev/null; then
command rm -rf "${TARBALL}" "${tmpdir}"
Expand Down