From e631cb8d1575ad9f918c92eea83eb95d1862b7b5 Mon Sep 17 00:00:00 2001 From: Tristan Maat Date: Mon, 17 Jul 2017 13:15:35 +0100 Subject: source.py: Fix missing files when calculating sha256sum --- buildstream/source.py | 13 +++++++++---- 1 file 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() -- cgit v1.2.1