diff options
author | Jürg Billeter <j@bitron.ch> | 2019-02-24 11:40:56 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2019-02-28 12:01:15 +0100 |
commit | 8be33e19e9c6b989da2c98f64c00a17882af0301 (patch) | |
tree | 46d95965729cccf41318afc0d44f853b8e7f08c5 | |
parent | 8f121ffc8ab71411cd11c561c3be5d7fcf74761c (diff) | |
download | buildstream-8be33e19e9c6b989da2c98f64c00a17882af0301.tar.gz |
element.py: Add __get_extract_key() method
-rw-r--r-- | buildstream/element.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/buildstream/element.py b/buildstream/element.py index 365931e27..b99e6fb4d 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -2676,6 +2676,25 @@ class Element(Plugin): self.__whitelist_regex = re.compile(expression) return self.__whitelist_regex.match(os.path.join(os.sep, path)) + # __get_extract_key(): + # + # Get the key used to extract the artifact + # + # Returns: + # (str): The key + # + def __get_extract_key(self): + + context = self._get_context() + key = self.__strict_cache_key + + # Use weak cache key, if artifact is missing for strong cache key + # and the context allows use of weak cache keys + if not context.get_strict() and not self.__artifacts.contains(self, key): + key = self._get_cache_key(strength=_KeyStrength.WEAK) + + return key + # __extract(): # # Extract an artifact and return the directory @@ -2691,13 +2710,7 @@ class Element(Plugin): def __extract(self, key=None): if key is None: - context = self._get_context() - key = self.__strict_cache_key - - # Use weak cache key, if artifact is missing for strong cache key - # and the context allows use of weak cache keys - if not context.get_strict() and not self.__artifacts.contains(self, key): - key = self._get_cache_key(strength=_KeyStrength.WEAK) + key = self.__get_extract_key() return (self.__artifacts.extract(self, key), key) |