diff options
Diffstat (limited to 'tests/sources/previous_source_access/plugins/sources/foo_transform.py')
-rw-r--r-- | tests/sources/previous_source_access/plugins/sources/foo_transform.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/tests/sources/previous_source_access/plugins/sources/foo_transform.py b/tests/sources/previous_source_access/plugins/sources/foo_transform.py index 906a8f6be..dbc44c8aa 100644 --- a/tests/sources/previous_source_access/plugins/sources/foo_transform.py +++ b/tests/sources/previous_source_access/plugins/sources/foo_transform.py @@ -10,7 +10,7 @@ previous sources, and copies its contents to a file called "filetransform". import os import hashlib -from buildstream import Consistency, Source, SourceError, utils +from buildstream import Source, SourceError, utils class FooTransformSource(Source): @@ -39,19 +39,18 @@ class FooTransformSource(Source): def get_unique_key(self): return (self.ref,) - def get_consistency(self): - if self.ref is None: - return Consistency.INCONSISTENT + def is_cached(self): # If we have a file called "filetransform", verify that its checksum - # matches our ref. Otherwise, it resolved but not cached. + # matches our ref. Otherwise, it is not cached. fpath = os.path.join(self.mirror, "filetransform") try: with open(fpath, "rb") as f: if hashlib.sha256(f.read()).hexdigest() == self.ref.strip(): - return Consistency.CACHED - except Exception: + return True + except FileNotFoundError: pass - return Consistency.RESOLVED + + return False def get_ref(self): return self.ref |