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 05:14:47 +0100 |
commit | 34ef71af2e6e6c378380be3c14d863ae4887bf02 (patch) | |
tree | ada7891e1131a470309dcc72fb79ace6ef25bf23 | |
parent | 153f81a10dcf558fcc4a7a796d1a3f48c21d9be9 (diff) | |
download | buildstream-34ef71af2e6e6c378380be3c14d863ae4887bf02.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) |