diff options
author | Tristan Maat <tristan.maat@codethink.com> | 2017-07-17 13:15:35 +0100 |
---|---|---|
committer | Tristan Maat <tristan.maat@codethink.com> | 2017-07-17 13:16:12 +0100 |
commit | e631cb8d1575ad9f918c92eea83eb95d1862b7b5 (patch) | |
tree | 165db0d925a93b35f8b171ed54a942c60034df45 | |
parent | 436dec968d4e631491346376d1e625aef605c653 (diff) | |
download | buildstream-workspaces.tar.gz |
source.py: Fix missing files when calculating sha256sumworkspaces
-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() |