Commit 37e5362e authored by Jürg Billeter's avatar Jürg Billeter Allow pulling strict artifacts in non-strict mode

Remotely cached artifacts matching the strict cache key take precedence
over locally cached artifacts matching only the weak cache key. However,
locally cached artifacts were excluded from the build plan, which means
that BuildStream never even checked whether the strict artifact is
available in the remote artifact cache.

This changes planning to keep cached elements in the build plan in
non-strict mode if a remote artifact cache is used.
parent 6d71826e
......@@ -193,7 +193,11 @@ class Pipeline():
# (list of Element): A depth sorted list of the build plan
def plan(self, elements):
return _Planner().plan(elements)
# Keep locally cached elements in the plan if remote artifact cache is used
# to allow pulling artifact with strict cache key, if available.
plan_cached = not self._context.get_strict() and self._artifacts.has_fetch_remotes()
return _Planner().plan(elements, plan_cached)
# get_selection()
......@@ -478,9 +482,9 @@ class _Planner():
self.depth_map[element] = depth
def plan(self, roots):
def plan(self, roots, plan_cached):
for root in roots:
self.plan_element(root, 0)
depth_sorted = sorted(self.depth_map.items(), key=itemgetter(1), reverse=True)
return [item[0] for item in depth_sorted if not item[0]._cached()]
return [item[0] for item in depth_sorted if plan_cached or not item[0]._cached()]
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment