summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-01-22 11:57:06 -0500
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-04-14 16:54:30 +0900
commit3d648aa032e31fcaeb8b9ef7bee7be18c9d802f4 (patch)
tree4f5ff6e5dc755026d06502de1c313384dcd72e4e
parent17a15a4691693444cdf37bd8687e252fe12463a4 (diff)
downloadbuildstream-3d648aa032e31fcaeb8b9ef7bee7be18c9d802f4.tar.gz
_artifactcache.py: Added client progress callback to ArtifactCache.clean()
-rw-r--r--buildstream/_artifactcache/artifactcache.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py
index a9a1869f0..0beab5537 100644
--- a/buildstream/_artifactcache/artifactcache.py
+++ b/buildstream/_artifactcache/artifactcache.py
@@ -276,10 +276,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
@@ -361,6 +364,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" +