summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Ennis <james.ennis@codethink.com>2019-01-11 11:47:47 +0000
committerJames Ennis <james.ennis@codethink.com>2019-01-17 12:36:02 +0000
commite992e41cbda69af7453c2903e8c414b5f87951d4 (patch)
treed0812ebc21e74803bfa29bc6d1138c6de1bdce6b
parentab6740f9b34e773b512370fd05d9d112e4347d38 (diff)
downloadbuildstream-e992e41cbda69af7453c2903e8c414b5f87951d4.tar.gz
artifactcache.py: Add prune() method to ArtifactCache
Removal/pruning should be handled by ArtifactCache API. We should not be using CASCache methods to remove BuildStream's artifacts.
-rw-r--r--buildstream/_artifactcache.py19
-rw-r--r--buildstream/_cas/cascache.py1
2 files changed, 16 insertions, 4 deletions
diff --git a/buildstream/_artifactcache.py b/buildstream/_artifactcache.py
index 16bde737b..7bd5a531d 100644
--- a/buildstream/_artifactcache.py
+++ b/buildstream/_artifactcache.py
@@ -462,8 +462,7 @@ class ArtifactCache():
# (int|None) The amount of space pruned from the repository in
# Bytes, or None if defer_prune is True
#
- def remove(self, ref):
-
+ def remove(self, ref, *, defer_prune=False):
# Remove extract if not used by other ref
tree = self.cas.resolve_ref(ref)
ref_name, ref_hash = os.path.split(ref)
@@ -482,7 +481,21 @@ class ArtifactCache():
if remove_extract:
utils._force_rmtree(extract)
- return self.cas.remove(ref)
+ return self.cas.remove(ref, defer_prune=defer_prune)
+
+ # prune():
+ #
+ # Prunes the artifact cache of objects which are unreachable from
+ # the repo
+ #
+ # Args:
+ # None
+ #
+ # Returns:
+ # (int) The amount of space pruned from the repository in bytes
+ #
+ def prune(self):
+ return self.cas.prune()
# extract():
#
diff --git a/buildstream/_cas/cascache.py b/buildstream/_cas/cascache.py
index adbd34c9e..f3eeb8876 100644
--- a/buildstream/_cas/cascache.py
+++ b/buildstream/_cas/cascache.py
@@ -543,7 +543,6 @@ class CASCache():
# Bytes, or None if defer_prune is True
#
def remove(self, ref, *, defer_prune=False):
-
# Remove cache ref
refpath = self._refpath(ref)
if not os.path.exists(refpath):