summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2020-04-19 10:40:25 +0200
committerJürg Billeter <j@bitron.ch>2020-04-19 10:48:54 +0200
commit90e1002d23dbadd95b7df16af65cb9191fa685d8 (patch)
treea69cc204ff9d15ea855798a0551b3dc4c1610913
parentfcacdf0e262b440743f3ef130d6ec389a4ffa16a (diff)
downloadbuildstream-90e1002d23dbadd95b7df16af65cb9191fa685d8.tar.gz
_artifact.py: Don't cache the proto of incomplete artifacts
We need to make sure that we read the new proto after a fresh build. And there is no need to keep the proto around for an incomplete artifact. This fixes `FileNotFoundError` of CAS blob on push after rebuild.
-rw-r--r--src/buildstream/_artifact.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/buildstream/_artifact.py b/src/buildstream/_artifact.py
index 7fe98dfaa..0a70d096f 100644
--- a/src/buildstream/_artifact.py
+++ b/src/buildstream/_artifact.py
@@ -423,8 +423,7 @@ class Artifact:
context = self._context
- artifact = self._get_proto()
-
+ artifact = self._load_proto()
if not artifact:
self._cached = False
return False
@@ -450,6 +449,7 @@ class Artifact:
self._cached = False
return False
+ self._proto = artifact
self._cached = True
return True
@@ -472,6 +472,7 @@ class Artifact:
# is cached or not.
#
def reset_cached(self):
+ self._proto = None
self._cached = None
# set_cached()
@@ -480,18 +481,15 @@ class Artifact:
# This is used as optimization when we know the artifact is available.
#
def set_cached(self):
+ self._proto = self._load_proto()
self._cached = True
- # _get_proto()
+ # load_proto()
#
# Returns:
# (Artifact): Artifact proto
#
- def _get_proto(self):
- # Check if we've already cached the proto object
- if self._proto is not None:
- return self._proto
-
+ def _load_proto(self):
key = self.get_extract_key()
proto_path = os.path.join(self._artifactdir, self._element.get_artifact_name(key=key))
@@ -503,9 +501,15 @@ class Artifact:
return None
os.utime(proto_path)
- # Cache the proto object
- self._proto = artifact
+ return artifact
+
+ # _get_proto()
+ #
+ # Returns:
+ # (Artifact): Artifact proto
+ #
+ def _get_proto(self):
return self._proto
# _get_field_digest()