Skip to content

Commit 56a71c7

Browse files
Buguinljharb
authored andcommitted
Skip checksum when download file failed.
1 parent a1601ed commit 56a71c7

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

nvm.sh

+18-12
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,21 @@ nvm_download() {
121121
if nvm_curl_use_compression; then
122122
CURL_COMPRESSED_FLAG="--compressed"
123123
fi
124-
curl --fail ${CURL_COMPRESSED_FLAG:-} -q "$@"
124+
# shellcheck disable=SC1083
125+
curl --fail ${CURL_COMPRESSED_FLAG:-} -q -w %{http_code} "$@"
125126
elif nvm_has "wget"; then
126127
# Emulate curl with wget
127128
ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
128-
-e 's/--compressed //' \
129-
-e 's/--fail //' \
130-
-e 's/-L //' \
131-
-e 's/-I /--server-response /' \
132-
-e 's/-s /-q /' \
133-
-e 's/-sS /-nv /' \
134-
-e 's/-o /-O /' \
135-
-e 's/-C - /-c /')
129+
-e 's/--compressed //' \
130+
-e 's/--fail //' \
131+
-e 's/-L //' \
132+
-e 's/-I /--server-response /' \
133+
-e 's/-s /-q /' \
134+
-e 's/-sS /-nv /' \
135+
-e 's/-o /-O /' \
136+
-e 's/-C - /-c /')
136137
# shellcheck disable=SC2086
137-
eval wget $ARGS
138+
eval wget -S $ARGS 2>&1 | grep '^ HTTP/' | awk '{print $2}'
138139
fi
139140
}
140141

@@ -2298,12 +2299,17 @@ nvm_download_artifact() {
22982299
nvm_err "Removing the broken local cache..."
22992300
command rm -rf "${TARBALL}"
23002301
fi
2302+
23012303
nvm_err "Downloading ${TARBALL_URL}..."
2302-
nvm_download -L -C - "${PROGRESS_BAR}" "${TARBALL_URL}" -o "${TARBALL}" || (
2304+
download_result=$(nvm_download -L -C - "${PROGRESS_BAR}" "${TARBALL_URL}" -o "${TARBALL}")
2305+
if [ "${NVM_DEBUG-}" = 1 ]; then
2306+
nvm_err "Download HTTP Status ${download_result}"
2307+
fi
2308+
if [ "${download_result}" != '200' ]; then
23032309
command rm -rf "${TARBALL}" "${tmpdir}"
23042310
nvm_err "Binary download from ${TARBALL_URL} failed, trying source."
23052311
return 4
2306-
)
2312+
fi
23072313

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

0 commit comments

Comments
 (0)