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.
This commit is contained in:
Ximin Luo 2016-07-04 16:37:46 +02:00
parent d508de6cf7
commit ab5309e9e8
2 changed files with 8 additions and 2 deletions

View File

@ -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))

View File

@ -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'