diff options
author | Benjamin Schubert <bschubert15@bloomberg.net> | 2019-11-28 10:59:52 +0000 |
---|---|---|
committer | Benjamin Schubert <bschubert15@bloomberg.net> | 2020-01-15 11:54:58 +0000 |
commit | f6b40474ec7470beffce5600e1a6266b2b352774 (patch) | |
tree | fa7226867cf32c42e53ef706b8d68280df51069a /src/buildstream/plugins/sources/_downloadablefilesource.py | |
parent | 7a8772b7872363d867ce1963ab6d0e7a587b3d05 (diff) | |
download | buildstream-f6b40474ec7470beffce5600e1a6266b2b352774.tar.gz |
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
Diffstat (limited to 'src/buildstream/plugins/sources/_downloadablefilesource.py')
-rw-r--r-- | src/buildstream/plugins/sources/_downloadablefilesource.py | 3 |
1 files changed, 3 insertions, 0 deletions
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 |