diff options
author | Tristan Maat <tristan.maat@codethink.com> | 2017-07-17 13:15:35 +0100 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-07-17 23:03:00 +0900 |
commit | d77ce40533f76f1164c1ef277cc7c816d42a2fa8 (patch) | |
tree | 7d86c6ff212767f139695a076d27a3dc5f67f825 | |
parent | b19607e7b3ed4cfcdc6f6f839a90df65f84a674d (diff) | |
download | buildstream-d77ce40533f76f1164c1ef277cc7c816d42a2fa8.tar.gz |
source.py: Fix missing files when calculating sha256sum
-rw-r--r-- | buildstream/source.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/buildstream/source.py b/buildstream/source.py index 015acf549..fcd4d6256 100644 --- a/buildstream/source.py +++ b/buildstream/source.py @@ -25,7 +25,7 @@ import shutil from contextlib import contextmanager from . import _yaml, _signals, utils -from . import ImplError +from . import ImplError, LoadError, LoadErrorReason from . import Plugin @@ -327,7 +327,12 @@ def sha256sum(filename): return "0" h = hashlib.sha256() - with open(filename, "rb") as f: - for chunk in iter(lambda: f.read(4096), b""): - h.update(chunk) + try: + with open(filename, "rb") as f: + for chunk in iter(lambda: f.read(4096), b""): + h.update(chunk) + except FileNotFoundError as e: + raise LoadError(LoadErrorReason.MISSING_FILE, + "Failed loading workspace. Did you remove the workspace directory? {}".format(e)) + return h.hexdigest() |