summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2019-04-02 10:18:37 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-04-09 09:12:43 +0000
commit95565a6b899e5af9c668339b6fb319e6f25c52f2 (patch)
treeff1a6d9e6f8cf0de8ce06cb1d8aa91bc6e2ac15c
parentbb75626c4c61fb1128b2cb22cfc63561cf7cd006 (diff)
downloadbuildstream-aevri/pass_funcs_not_generators.tar.gz
{artifact,source,cas}cache: fix one-shot callbacksaevri/pass_funcs_not_generators
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.
-rw-r--r--buildstream/_artifactcache.py2
-rw-r--r--buildstream/_cas/cascache.py6
-rw-r--r--buildstream/_sourcecache.py2
3 files changed, 7 insertions, 3 deletions
diff --git a/buildstream/_artifactcache.py b/buildstream/_artifactcache.py
index 5fd646137..fb0670e3e 100644
--- a/buildstream/_artifactcache.py
+++ b/buildstream/_artifactcache.py
@@ -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():
diff --git a/buildstream/_cas/cascache.py b/buildstream/_cas/cascache.py
index c739c7ee1..eae3ef04d 100644
--- a/buildstream/_cas/cascache.py
+++ b/buildstream/_cas/cascache.py
@@ -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()
diff --git a/buildstream/_sourcecache.py b/buildstream/_sourcecache.py
index 219ecb1e9..36f75d040 100644
--- a/buildstream/_sourcecache.py
+++ b/buildstream/_sourcecache.py
@@ -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()