source.py: Fix missing files when calculating sha256sum
diff --git a/buildstream/source.py b/buildstream/source.py index 015acf5..fcd4d62 100644 --- a/buildstream/source.py +++ b/buildstream/source.py
@@ -25,7 +25,7 @@ from contextlib import contextmanager from . import _yaml, _signals, utils -from . import ImplError +from . import ImplError, LoadError, LoadErrorReason from . import Plugin @@ -327,7 +327,12 @@ 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()