Skip to content

Commit ab5309e

Browse files
committed
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.
1 parent d508de6 commit ab5309e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/bootstrap/bootstrap.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ def get(url, path, verbose=False):
3131

3232
try:
3333
download(sha_path, sha_url, verbose)
34+
if os.path.exists(path):
35+
try:
36+
verify(path, sha_path, verbose)
37+
print("using already-download file " + path)
38+
return
39+
except Exception as e:
40+
print("failed verification for already-download file " + path)
41+
os.unlink(path)
3442
download(temp_path, url, verbose)
3543
verify(temp_path, sha_path, verbose)
3644
print("moving {} to {}".format(temp_path, path))

src/etc/get-stage0.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ def main(triple):
3131
filename = 'rustc-{}-{}.tar.gz'.format(channel, triple)
3232
url = 'https://static.rust-lang.org/dist/{}/{}'.format(date, filename)
3333
dst = dl_dir + '/' + filename
34-
if os.path.exists(dst):
35-
os.unlink(dst)
3634
bootstrap.get(url, dst)
3735

3836
stage0_dst = triple + '/stage0'

0 commit comments

Comments
 (0)