From 49c11bc8398f79c8a97806db75978c0c425f5244 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Tue, 22 Jan 2019 11:57:06 -0500 Subject: _artifactcache.py: Added client progress callback to ArtifactCache.clean() --- buildstream/_artifactcache.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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" + -- cgit v1.2.1