summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Ennis <james.ennis@codethink.com>2019-01-11 12:13:15 +0000
committerJames Ennis <james.ennis@codethink.com>2019-01-17 12:36:02 +0000
commit1050e97ca0b87ca2b7cd48ee4b9e1d135904cd54 (patch)
tree2149c46f427046160bb823b5740b9ece5a68ed51
parente992e41cbda69af7453c2903e8c414b5f87951d4 (diff)
downloadbuildstream-1050e97ca0b87ca2b7cd48ee4b9e1d135904cd54.tar.gz
cli.py: Defer pruning until all specified refs are removed
-rw-r--r--buildstream/_frontend/cli.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index 28e60272b..f2bf45c50 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -1101,13 +1101,19 @@ def artifact_delete(app, artifacts):
if element is not None:
elements = [element]
+ # Remove specified elements and artifacts
if elements:
elements = app.stream.load_selection(elements, selection=PipelineSelection.NONE)
for element in elements:
- cache.remove(cache.get_artifact_fullname(element, element._get_cache_key()))
+ cache_key = element._get_cache_key()
+ ref = cache.get_artifact_fullname(element, cache_key)
+ cache.remove(ref, defer_prune=True)
if artifacts:
- for i, ref in enumerate(artifacts, start=1):
- cache.cas.remove(ref, defer_prune=(i != len(artifacts)))
+ for ref in artifacts:
+ cache.remove(ref, defer_prune=True)
+
+ # Now we've removed all the refs, prune the unreachable objects
+ cache.prune()
##################################################################