From f6b40474ec7470beffce5600e1a6266b2b352774 Mon Sep 17 00:00:00 2001 From: Benjamin Schubert Date: Thu, 28 Nov 2019 10:59:52 +0000 Subject: source.py: Remove the reliance on consistency to get whether a source is cached This removes the need to use consistency in Sources, by asking explicitely whether the source is cached or not. This introduces a new public method on source: `is_cached` that needs implementation and that should return whether the source has a local copy or not. - On fetch, also reset whether the source was cached or set if as cached when we know it was. - Validate the cache's source after fetching it This doesn't need to be run in the scheduler's process and can be offloaded to the child, which will allow better multiprocessing --- src/buildstream/plugins/sources/_downloadablefilesource.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/buildstream/plugins/sources/_downloadablefilesource.py') diff --git a/src/buildstream/plugins/sources/_downloadablefilesource.py b/src/buildstream/plugins/sources/_downloadablefilesource.py index 4e43ee3e3..581d32e7d 100644 --- a/src/buildstream/plugins/sources/_downloadablefilesource.py +++ b/src/buildstream/plugins/sources/_downloadablefilesource.py @@ -88,6 +88,9 @@ class DownloadableFileSource(Source): def get_unique_key(self): return [self.original_url, self.ref] + def is_cached(self) -> bool: + return os.path.isfile(self._get_mirror_file()) + def get_consistency(self): if self.ref is None: return Consistency.INCONSISTENT -- cgit v1.2.1