diff options
author | Jürg Billeter <j@bitron.ch> | 2017-07-18 11:16:19 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2017-07-20 07:24:56 +0200 |
commit | 0a1ad73cd3ab993f85e2933433d1ae4f835517b6 (patch) | |
tree | ab1aa4cff35ddbdff33c458c8e89ed3b21c6694b | |
parent | c37662f3088e0fe2c9647fa2a57c3336dac78135 (diff) | |
download | buildstream-0a1ad73cd3ab993f85e2933433d1ae4f835517b6.tar.gz |
element.py: Add _remotely_cached()
-rw-r--r-- | buildstream/element.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/buildstream/element.py b/buildstream/element.py index 1ec5061b8..81f4a1626 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -115,6 +115,7 @@ class Element(Plugin): self.__cache_key_from_artifact = None # Our cached cache key from artifact self.__artifacts = artifacts # Artifact cache self.__cached = None # Whether we have a cached artifact + self.__remotely_cached = None # Whether we have a remotely cached artifact self.__built = False # Element was locally built self.__log_path = None # Path to dedicated log file or None self.__splits = None @@ -720,6 +721,42 @@ class Element(Plugin): raise ElementError("{}: Missing artifact {}" .format(self, self._get_display_key())) + # _remotely_cached(): + # + # Args: + # recalculate (bool): Whether to forcefully recalculate + # + # Returns: + # (bool): Whether this element is already present in + # the remote artifact cache + # + # Note: The recalculate argument is actually tristate: + # + # o None: Calculate cache state if not previously calculated + # o True: Force recalculate cached state, even if already checked + # o False: Only return cached state, never recalculate automatically + # + def _remotely_cached(self, recalculate=None, strength=None): + + if recalculate: + self.__remotely_cached = None + self.__remotely_strong_cached = None + + if strength is None: + strength = _KeyStrength.STRONG if self.get_context().strict_build_plan else _KeyStrength.WEAK + + if recalculate is not False: + if self.__remotely_cached is None and self._get_cache_key() is not None: + self.__remotely_cached = self.__artifacts.remote_contains(self) + self.__remotely_strong_cached = self.__artifacts.remote_contains(self, strength=_KeyStrength.STRONG) + + if self.__remotely_cached is None: + return False + elif strength == _KeyStrength.STRONG: + return self.__remotely_strong_cached + else: + return self.__remotely_cached + # _tainted(): # # Whether this artifact should be pushed to an artifact cache. |