From bb7bd9767a5b7134788d550d67295f8566883208 Mon Sep 17 00:00:00 2001 From: Rust Maintainers Date: Sun, 9 Jul 2017 00:35:25 +0100 Subject: [PATCH] d-dont-download-stage0 Gbp-Pq: Name d-dont-download-stage0.patch --- src/bootstrap/bootstrap.py | 11 ++++++----- src/etc/get-stage0.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 04cc6efc98..4956ad54e0 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -22,15 +22,17 @@ import tempfile from time import time -def get(url, path, verbose=False): +def get(url, path, verbose=False, use_local_hash_if_present=False): sha_url = url + ".sha256" with tempfile.NamedTemporaryFile(delete=False) as temp_file: temp_path = temp_file.name - with tempfile.NamedTemporaryFile(suffix=".sha256", delete=False) as sha_file: - sha_path = sha_file.name + sha_path = path + ".sha256" try: - download(sha_path, sha_url, False, verbose) + if use_local_hash_if_present and os.path.exists(sha_path): + print("using already-download file " + sha_path) + else: + download(sha_path, sha_url, False, verbose) if os.path.exists(path): if verify(path, sha_path, False): if verbose: @@ -47,7 +49,6 @@ def get(url, path, verbose=False): print("moving {} to {}".format(temp_path, path)) shutil.move(temp_path, path) finally: - delete_if_present(sha_path, verbose) delete_if_present(temp_path, verbose) diff --git a/src/etc/get-stage0.py b/src/etc/get-stage0.py index 127251cc80..4b89c59b5d 100644 --- a/src/etc/get-stage0.py +++ b/src/etc/get-stage0.py @@ -31,7 +31,7 @@ def main(triple): filename = 'rustc-{}-{}.tar.gz'.format(channel, triple) url = 'https://static.rust-lang.org/dist/{}/{}'.format(date, filename) dst = dl_dir + '/' + filename - bootstrap.get(url, dst) + bootstrap.get(url, dst, use_local_hash_if_present=True) stage0_dst = triple + '/stage0' if os.path.exists(stage0_dst): -- 2.30.2