diff options
author | Jürg Billeter <j@bitron.ch> | 2017-07-18 12:32:58 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2017-07-20 07:24:56 +0200 |
commit | 38a24fa7beff65d597db10a46b5bb35e760d2763 (patch) | |
tree | d09744ea7c4fecf374d373ea43dbca098603fa03 | |
parent | fc65bf7ba5ede46f863e59f6b4bb4bc7b60d1735 (diff) | |
download | buildstream-38a24fa7beff65d597db10a46b5bb35e760d2763.tar.gz |
_artifactcache: Do not attempt to pull unavailable artifacts
-rw-r--r-- | buildstream/_artifactcache/artifactcache.py | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py index d65dc4700..6be654210 100644 --- a/buildstream/_artifactcache/artifactcache.py +++ b/buildstream/_artifactcache/artifactcache.py @@ -230,25 +230,21 @@ class ArtifactCache(): raise _ArtifactError("Attempt to pull artifact without any pull URL") weak_ref = buildref(element, element._get_cache_key(strength=_KeyStrength.WEAK)) - try: - # try fetching the artifact using the strong cache key - ref = buildref(element, element._get_cache_key()) - _ostree.fetch(self.repo, remote=remote, - ref=ref, progress=progress) - # resolve ref to checksum - rev = _ostree.checksum(self.repo, ref) + try: + if self.remote_contains(element, strength=_KeyStrength.STRONG): + # fetch the artifact using the strong cache key + ref = buildref(element, element._get_cache_key()) + _ostree.fetch(self.repo, remote=remote, + ref=ref, progress=progress) - # update weak ref by pointing it to this newly fetched artifact - _ostree.set_ref(self.repo, weak_ref, rev) - except OSTreeError as e: - # fetch the artifact using the weak cache key, if the context allows it - # (and it's not already in the local cache) - if self.context.strict_build_plan or element._cached(): - raise _ArtifactError("Failed to pull artifact for element {}: {}" - .format(element.name, e)) from e + # resolve ref to checksum + rev = _ostree.checksum(self.repo, ref) - try: + # update weak ref by pointing it to this newly fetched artifact + _ostree.set_ref(self.repo, weak_ref, rev) + elif self.remote_contains(element): + # fetch the artifact using the weak cache key _ostree.fetch(self.repo, remote=remote, ref=weak_ref, progress=progress) @@ -261,9 +257,12 @@ class ArtifactCache(): # create tag for strong cache key _ostree.set_ref(self.repo, ref, rev) - except OSTreeError as e: - raise _ArtifactError("Failed to pull artifact for element {}: {}" - .format(element.name, e)) from e + else: + raise _ArtifactError("Attempt to pull unavailable artifact for element {}" + .format(element.name)) + except OSTreeError as e: + raise _ArtifactError("Failed to pull artifact for element {}: {}" + .format(element.name, e)) from e # fetch_remote_refs(): # |