Commit 95565a6b authored by Angelos Evripiotis's avatar Angelos Evripiotis Committed by bst-marge-bot

{artifact,source,cas}cache: fix one-shot callbacks

Remove the unintended side-effect of only being able to iterate the
ref_callbacks results once. This would mean that subsequent calls to
clean() were not honoring the required_refs correctly.

Update CasQuota.clean() to call the ref callbacks and iterate over
their results.

When registering ref callbacks; pass the methods, and not the generators
that they return.
parent bb75626c
Pipeline #55879731 passed with stages
in 93 minutes and 4 seconds
......@@ -55,7 +55,7 @@ class ArtifactCache(BaseCache):
self._required_elements = set() # The elements required for this session
self.casquota.add_ref_callbacks(self.required_artifacts())
self.casquota.add_ref_callbacks(self.required_artifacts)
self.casquota.add_remove_callbacks((lambda x: not x.startswith('@'), self.remove))
# mark_required_elements():
......
......@@ -1383,7 +1383,11 @@ class CASQuota:
# get required refs
refs = self.cas.list_refs()
required_refs = set(itertools.chain.from_iterable(self._ref_callbacks))
required_refs = set(
required
for callback in self._ref_callbacks
for required in callback()
)
# Start off with an announcement with as much info as possible
volume_size, volume_avail = self._get_cache_volume_size()
......
......@@ -53,7 +53,7 @@ class SourceCache(BaseCache):
self._required_sources = set()
self.casquota.add_ref_callbacks(self.required_sources())
self.casquota.add_ref_callbacks(self.required_sources)
self.casquota.add_remove_callbacks((lambda x: x.startswith('@sources/'), self.cas.remove))
# mark_required_sources()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment