summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbderrahim Kitouni <akitouni@gnome.org>2020-09-16 10:18:55 +0100
committerAbderrahim Kitouni <akitouni@gnome.org>2020-09-16 10:18:55 +0100
commit400a5ec7dda344618afdc5d37d3f282828e09cb5 (patch)
tree75253cfe08386b5d6aed4db58ca79ad7a8204c02
parentfc15a92b96327522bd3c722c2cf03f01219c3e68 (diff)
downloadbuildstream-abderrahim/cleanup-speedup.tar.gz
cascache.py: remove the code for pruning the local cacheabderrahim/cleanup-speedup
It's no longer used
-rw-r--r--buildstream/_artifactcache/artifactcache.py6
-rw-r--r--buildstream/_artifactcache/cascache.py45
-rw-r--r--buildstream/_artifactcache/casserver.py2
3 files changed, 3 insertions, 50 deletions
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py
index 29af36a7b..2a1ea75f3 100644
--- a/buildstream/_artifactcache/artifactcache.py
+++ b/buildstream/_artifactcache/artifactcache.py
@@ -600,10 +600,6 @@ class ArtifactCache():
# generated by
# `ArtifactCache.get_artifact_fullname`)
#
- # Returns:
- # (int|None) The amount of space pruned from the repository in
- # Bytes, or None if defer_prune is True
- #
def remove(self, ref):
# Remove extract if not used by other ref
@@ -624,7 +620,7 @@ class ArtifactCache():
if remove_extract:
utils._force_rmtree(extract)
- return self.cas.remove(ref, defer_prune=True)
+ self.cas.remove(ref)
# extract():
#
diff --git a/buildstream/_artifactcache/cascache.py b/buildstream/_artifactcache/cascache.py
index 9dd25b38e..cea28f7ed 100644
--- a/buildstream/_artifactcache/cascache.py
+++ b/buildstream/_artifactcache/cascache.py
@@ -578,15 +578,8 @@ class CASCache():
#
# Args:
# ref (str): A symbolic ref
- # defer_prune (bool): Whether to defer pruning to the caller. NOTE:
- # The space won't be freed until you manually
- # call prune.
#
- # Returns:
- # (int|None) The amount of space pruned from the repository in
- # Bytes, or None if defer_prune is True
- #
- def remove(self, ref, *, defer_prune=False):
+ def remove(self, ref):
# Remove cache ref
refpath = self._refpath(ref)
@@ -595,42 +588,6 @@ class CASCache():
os.unlink(refpath)
- if not defer_prune:
- pruned = self.prune()
- return pruned
-
- return None
-
- # prune():
- #
- # Prune unreachable objects from the repo.
- #
- def prune(self):
- ref_heads = os.path.join(self.casdir, 'refs', 'heads')
-
- pruned = 0
- reachable = set()
-
- # Check which objects are reachable
- for root, _, files in os.walk(ref_heads):
- for filename in files:
- ref_path = os.path.join(root, filename)
- ref = os.path.relpath(ref_path, ref_heads)
-
- tree = self.resolve_ref(ref)
- self._reachable_refs_dir(reachable, tree)
-
- # Prune unreachable objects
- for root, _, files in os.walk(os.path.join(self.casdir, 'objects')):
- for filename in files:
- objhash = os.path.basename(root) + filename
- if objhash not in reachable:
- obj_path = os.path.join(root, filename)
- pruned += os.stat(obj_path).st_size
- os.unlink(obj_path)
-
- return pruned
-
def update_tree_mtime(self, tree):
reachable = set()
self._reachable_refs_dir(reachable, tree, update_mtime=True)
diff --git a/buildstream/_artifactcache/casserver.py b/buildstream/_artifactcache/casserver.py
index 1fdab80a8..e6c3d9f65 100644
--- a/buildstream/_artifactcache/casserver.py
+++ b/buildstream/_artifactcache/casserver.py
@@ -380,7 +380,7 @@ class _ReferenceStorageServicer(buildstream_pb2_grpc.ReferenceStorageServicer):
try:
self.cas.update_tree_mtime(tree)
except FileNotFoundError:
- self.cas.remove(request.key, defer_prune=True)
+ self.cas.remove(request.key)
context.set_code(grpc.StatusCode.NOT_FOUND)
return response