summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-10-17 10:18:36 +0200
committerJürg Billeter <j@bitron.ch>2019-11-04 16:52:30 +0100
commitb300e20f7821a89aeb3ea88c2a27e6009bad8cb3 (patch)
treea7c328deefbf639fba4761f789d34c3b411f406c
parent9f713136d886473332897d96709a5f83209938ff (diff)
downloadbuildstream-b300e20f7821a89aeb3ea88c2a27e6009bad8cb3.tar.gz
element.py: Avoid redundant SourceCache.contains() calls
If the sources of an element are cached, they will stay cached for the duration of the bst session.
-rw-r--r--src/buildstream/element.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index a6b2af110..9a0a71a97 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -267,6 +267,7 @@ class Element(Plugin):
self.__tracking_scheduled = False # Sources are scheduled to be tracked
self.__pull_done = False # Whether pull was attempted
self.__cached_successfully = None # If the Element is known to be successfully cached
+ self.__source_cached = None # If the sources are known to be successfully cached
self.__splits = None # Resolved regex objects for computing split domains
self.__whitelist_regex = None # Resolved regex object to check if file is allowed to overlap
# Location where Element.stage_sources() was called
@@ -2173,6 +2174,9 @@ class Element(Plugin):
# Check if sources are cached, generating the source key if it hasn't been
def _source_cached(self):
+ if self.__source_cached is not None:
+ return self.__source_cached
+
if self.__sources:
sourcecache = self._get_context().sourcecache
@@ -2189,6 +2193,7 @@ class Element(Plugin):
if not sourcecache.contains(source):
return False
+ self.__source_cached = True
return True
def _should_fetch(self, fetch_original=False):