summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-05-06 19:36:47 +0900
committerTom Pollard <tom.pollard@codethink.co.uk>2019-05-07 12:24:17 +0100
commit9a9ee4102f89e5a360aaf58e14170e24cb9f51ef (patch)
tree291da65d7a56915e3f991da597fc42ca182c91dd
parent0a1b6ab7cb2f26502384761fe60e080051f14235 (diff)
downloadbuildstream-9a9ee4102f89e5a360aaf58e14170e24cb9f51ef.tar.gz
element.py: Reset workspace state if last successful build is missing.
If the artifact referred to by the last successful build in the workspace state no longer exists, reset the workspace state and do not attempt to perform an incremental build instead of crashing. This fixes #1017
-rw-r--r--buildstream/element.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/buildstream/element.py b/buildstream/element.py
index 8cc25fec6..cc31d3f02 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -738,8 +738,24 @@ class Element(Plugin):
context = self._get_context()
if self.__can_build_incrementally() and workspace.last_successful:
- last_successful = Artifact(self, context, strong_key=workspace.last_successful)
- old_dep_keys = last_successful.get_metadata_dependencies()
+
+ # Try to perform an incremental build if the last successful
+ # build is still in the artifact cache
+ #
+ if self.__artifacts.contains(self, workspace.last_successful):
+ last_successful = Artifact(self, context, strong_key=workspace.last_successful)
+ old_dep_keys = last_successful.get_metadata_dependencies()
+ else:
+ # Last successful build is no longer in the artifact cache,
+ # so let's reset it and perform a full build now.
+ workspace.prepared = False
+ workspace.last_successful = None
+
+ self.info("Resetting workspace state, last successful build is no longer in the cache")
+
+ # In case we are staging in the main process
+ if utils._is_main_process():
+ context.get_workspaces().save_config()
for dep in self.dependencies(scope):
# If we are workspaced, and we therefore perform an
@@ -764,7 +780,7 @@ class Element(Plugin):
# In case we are running `bst shell`, this happens in the
# main process and we need to update the workspace config
if utils._is_main_process():
- self._get_context().get_workspaces().save_config()
+ context.get_workspaces().save_config()
result = dep.stage_artifact(sandbox,
path=path,