diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-01-22 11:57:06 -0500 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-01-24 13:02:08 -0500 |
commit | 49c11bc8398f79c8a97806db75978c0c425f5244 (patch) | |
tree | 75bec0e6b080dd1070971e5b1a9bfbfb24dc929a | |
parent | 8074ebf4a704cacfe344d4df58076dd144bef636 (diff) | |
download | buildstream-49c11bc8398f79c8a97806db75978c0c425f5244.tar.gz |
_artifactcache.py: Added client progress callback to ArtifactCache.clean()
-rw-r--r-- | buildstream/_artifactcache.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/buildstream/_artifactcache.py b/buildstream/_artifactcache.py index a3365c2d3..e16e7d7d2 100644 --- a/buildstream/_artifactcache.py +++ b/buildstream/_artifactcache.py @@ -250,10 +250,13 @@ class ArtifactCache(): # # Clean the artifact cache as much as possible. # + # Args: + # progress (callable): A callback to call when a ref is removed + # # Returns: # (int): The size of the cache after having cleaned up # - def clean(self): + def clean(self, progress=None): artifacts = self.list_artifacts() context = self.context @@ -335,6 +338,14 @@ class ArtifactCache(): # Remove the size from the removed size self.set_cache_size(self._cache_size - size) + # User callback + # + # Currently this process is fairly slow, but we should + # think about throttling this progress() callback if this + # becomes too intense. + if progress: + progress() + # Informational message about the side effects of the cleanup self._message(MessageType.INFO, "Cleanup completed", detail=("Removed {} refs and saving {} disk space.\n" + |