Skip to content

Commit 13aac00

Browse files
committed
rustup: Add support for resuming downloads
1 parent 590499e commit 13aac00

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/etc/rustup.sh

+15-2
Original file line numberDiff line numberDiff line change
@@ -497,15 +497,28 @@ download_package() {
497497
remote_sha256="${remote_tarball}.sha256"
498498

499499
# Check if we've already downloaded this file.
500-
if [ ! -e "${local_tarball}" ]; then
500+
if [ -e "${local_tarball}.tmp" ]; then
501+
msg "Resuming ${remote_tarball} to ${local_tarball}"
502+
503+
"${CFG_CURL}" -f -C - -o "${local_tarball}.tmp" "${remote_tarball}"
504+
if [ $? -ne 0 ]
505+
then
506+
rm -Rf "${CFG_TMP_DIR}"
507+
err "failed to download installer"
508+
fi
509+
510+
mv "${local_tarball}.tmp" "${local_tarball}"
511+
elif [ ! -e "${local_tarball}" ]; then
501512
msg "Downloading ${remote_tarball} to ${local_tarball}"
502513

503-
"${CFG_CURL}" -f -o "${local_tarball} "${remote_tarball}"
514+
"${CFG_CURL}" -f -o "${local_tarball}.tmp" "${remote_tarball}"
504515
if [ $? -ne 0 ]
505516
then
506517
rm -Rf "${CFG_TMP_DIR}"
507518
err "failed to download installer"
508519
fi
520+
521+
mv "${local_tarball}.tmp" "${local_tarball}"
509522
fi
510523

511524
verify_hash "${remote_sha256}" "${local_tarball}"

0 commit comments

Comments
 (0)