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-20 14:27:16 +0200
commit70c4171aec75386ac2ecd889579402b17d87b7c0 (patch)
tree8d6a4bd6a0f4415df4952655f8bc1ba1f610597b
parentcc087ae947c92771def5699ac49cd88b472413d7 (diff)
downloadbuildstream-70c4171aec75386ac2ecd889579402b17d87b7c0.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()