diff options
| author | Ximin Luo <infinity0@pwned.gg> | 2016-07-04 16:37:46 +0200 |
|---|---|---|
| committer | Ximin Luo <infinity0@pwned.gg> | 2016-07-04 16:37:46 +0200 |
| commit | ab5309e9e8467508766aee176dc121672d606524 (patch) | |
| tree | b1f3e43472d88ffb7e397548551ed0a180863a91 | |
| parent | d508de6cf7c7bb9b5057ee63432dbbc899209101 (diff) | |
| download | rust-ab5309e9e8467508766aee176dc121672d606524.tar.gz rust-ab5309e9e8467508766aee176dc121672d606524.zip | |
Avoid redundant downloads when bootstrapping
If the local file is available, then verify it against the hash we just downloaded, and if it matches then we don't need to download it again.
| -rw-r--r-- | src/bootstrap/bootstrap.py | 8 | ||||
| -rw-r--r-- | src/etc/get-stage0.py | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 33de8fd0107..49f00bf46f1 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -31,6 +31,14 @@ def get(url, path, verbose=False): try: download(sha_path, sha_url, verbose) + if os.path.exists(path): + try: + verify(path, sha_path, verbose) + print("using already-download file " + path) + return + except Exception as e: + print("failed verification for already-download file " + path) + os.unlink(path) download(temp_path, url, verbose) verify(temp_path, sha_path, verbose) print("moving {} to {}".format(temp_path, path)) diff --git a/src/etc/get-stage0.py b/src/etc/get-stage0.py index 28e3363189a..127251cc802 100644 --- a/src/etc/get-stage0.py +++ b/src/etc/get-stage0.py @@ -31,8 +31,6 @@ def main(triple): filename = 'rustc-{}-{}.tar.gz'.format(channel, triple) url = 'https://static.rust-lang.org/dist/{}/{}'.format(date, filename) dst = dl_dir + '/' + filename - if os.path.exists(dst): - os.unlink(dst) bootstrap.get(url, dst) stage0_dst = triple + '/stage0' |
