diff options
| author | Ximin Luo <infinity0@pwned.gg> | 2016-07-06 00:07:26 +0200 |
|---|---|---|
| committer | Ximin Luo <infinity0@pwned.gg> | 2016-07-06 00:07:26 +0200 |
| commit | 912a9d0ad8e4c8b8a6c200d104a98982b3a07aeb (patch) | |
| tree | 71505651da6ccad699a63dec692c8fee908d32a5 /src/bootstrap/bootstrap.py | |
| parent | ab5309e9e8467508766aee176dc121672d606524 (diff) | |
| download | rust-912a9d0ad8e4c8b8a6c200d104a98982b3a07aeb.tar.gz rust-912a9d0ad8e4c8b8a6c200d104a98982b3a07aeb.zip | |
Have verify() return a bool rather than a generic RuntimeError
Diffstat (limited to 'src/bootstrap/bootstrap.py')
| -rw-r--r-- | src/bootstrap/bootstrap.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 49f00bf46f1..ce5ab9fab84 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -32,15 +32,15 @@ def get(url, path, verbose=False): try: download(sha_path, sha_url, verbose) if os.path.exists(path): - try: - verify(path, sha_path, verbose) + if verify(path, sha_path, verbose): print("using already-download file " + path) return - except Exception as e: - print("failed verification for already-download file " + path) + else: + print("ignoring already-download file " + path + " due to failed verification") os.unlink(path) download(temp_path, url, verbose) - verify(temp_path, sha_path, verbose) + if not verify(temp_path, sha_path, verbose): + raise RuntimeError("failed verification") print("moving {} to {}".format(temp_path, path)) shutil.move(temp_path, path) finally: @@ -72,13 +72,12 @@ def verify(path, sha_path, verbose): found = hashlib.sha256(f.read()).hexdigest() with open(sha_path, "r") as f: expected, _ = f.readline().split() - if found != expected: - err = ("invalid checksum:\n" + verified = found == expected + if not verified and verbose: + print("invalid checksum:\n" " found: {}\n" " expected: {}".format(found, expected)) - if verbose: - raise RuntimeError(err) - sys.exit(err) + return verified def unpack(tarball, dst, verbose=False, match=None): |
