pipeline: short-circuit if final object exists

If the final object, image, artifact, already exists in the store,
short-circuit and return directly from `Pipeline.run`. Otherwise
the situation might arise that the final result is in the store,
but the tree (and build trees) are not and thus the tree would be
built, just to be thrown away when the assembler phase detects
that the final output already exists.
This commit is contained in:
Christian Kellner 2020-03-06 15:18:31 +01:00 committed by Tom Gundersen
parent b755e69bca
commit 5d0f6aa981

View file

@ -336,6 +336,17 @@ class Pipeline:
results = {}
with objectstore.ObjectStore(store) as object_store:
# if the final result is already in the store, exit
# early and don't attempt to build the tree, which
# in turn might not be in the store and would in that
# case be build but not be used
if object_store.contains(self.output_id):
results = {"output_id": self.output_id,
"success": True}
if object_store.contains(self.tree_id):
results["tree_id"] = self.tree_id
return results
results, build_tree, tree = self.build_stages(object_store,
interactive,
libdir,