diff options
author | Raoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk> | 2019-03-01 18:03:04 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-03-25 11:46:44 +0000 |
commit | cc9441d4138ea7a4b490df0e618222ffbc2e0195 (patch) | |
tree | b25731a7c7fd95bb80c67e3656e52e53388681d6 | |
parent | 021942ba0b28fc23f825e1782645a0873b6c5b61 (diff) | |
download | buildstream-cc9441d4138ea7a4b490df0e618222ffbc2e0195.tar.gz |
element.py: Pull from sourcecache in _fetch()
Part of #440
-rw-r--r-- | buildstream/_scheduler/queues/fetchqueue.py | 7 | ||||
-rw-r--r-- | buildstream/element.py | 19 |
2 files changed, 17 insertions, 9 deletions
diff --git a/buildstream/_scheduler/queues/fetchqueue.py b/buildstream/_scheduler/queues/fetchqueue.py index 546c65b65..9edeebb1d 100644 --- a/buildstream/_scheduler/queues/fetchqueue.py +++ b/buildstream/_scheduler/queues/fetchqueue.py @@ -73,5 +73,8 @@ class FetchQueue(Queue): element._fetch_done() - # Successful fetch, we must be CACHED now - assert element._get_consistency() == Consistency.CACHED + # Successful fetch, we must be CACHED or in the sourcecache + if self._fetch_original: + assert element._get_consistency() == Consistency.CACHED + else: + assert element._source_cached() diff --git a/buildstream/element.py b/buildstream/element.py index 39b61cf5b..9432aa018 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -2112,15 +2112,20 @@ class Element(Plugin): # def _fetch(self, fetch_original=False): previous_sources = [] - source = None - - # check whether the final source is cached - for source in self.sources(): - pass + sources = self.__sources + if sources and not fetch_original: + source = sources[-1] + if self.__sourcecache.contains(source): + return - if source and not fetch_original and self.__sourcecache.contains(source): - return + # try and fetch from source cache + if source._get_consistency() < Consistency.CACHED and \ + self.__sourcecache.has_fetch_remotes() and \ + not self.__sourcecache.contains(source): + if self.__sourcecache.pull(source): + return + # We need to fetch original sources for source in self.sources(): source_consistency = source._get_consistency() if source_consistency != Consistency.CACHED: |