Skip to content

Commit 550255d

Browse files
committed
rollup merge of #21138: mkpankov/master
When combined with '--save' and '--date', it uses previously saved tarball, making possible to re-install in offline mode. r?
2 parents 2e9adab + 785176b commit 550255d

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/etc/rustup.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,16 +453,33 @@ then
453453
RUST_URL="${RUST_URL}/${CFG_DATE}"
454454
fi
455455

456-
verify_hash() {
457-
remote_sha256="$1"
458-
local_file="$2"
459-
456+
download_hash() {
460457
msg "Downloading ${remote_sha256}"
461458
remote_sha256=`"${CFG_CURL}" -f "${remote_sha256}"`
459+
if [ -n "${CFG_SAVE}" ]; then
460+
echo "${remote_sha256}" > "${local_sha_file}"
461+
fi
462462
if [ "$?" -ne 0 ]; then
463463
rm -Rf "${CFG_TMP_DIR}"
464464
err "Failed to download ${remote_url}"
465465
fi
466+
}
467+
468+
verify_hash() {
469+
remote_sha256="$1"
470+
local_file="$2"
471+
local_sha_file="${local_file}.sha256"
472+
473+
if [ -n "${CFG_SAVE}" ]; then
474+
if [ -f "${local_sha_file}" ]; then
475+
msg "Local ${local_sha_file} exists, treating as remote hash"
476+
remote_sha256=`cat "${local_sha_file}"`
477+
else
478+
download_hash
479+
fi
480+
else
481+
download_hash
482+
fi
466483

467484
msg "Verifying hash"
468485
local_sha256=$(calculate_hash "${local_file}")

0 commit comments

Comments
 (0)