You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:42:08 UTC

[buildstream] 01/08: cli: Add artifact delete subcommand

This is an automated email from the ASF dual-hosted git repository.

not-in-ldap pushed a commit to branch jennis/new_artifact_subcommands
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit ab6740f9b34e773b512370fd05d9d112e4347d38
Author: Richard Maw <ri...@codethink.co.uk>
AuthorDate: Wed Dec 12 18:37:53 2018 +0000

    cli: Add artifact delete subcommand
---
 buildstream/_frontend/cli.py | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index b3e48d5..28e6027 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -1080,6 +1080,36 @@ def artifact_log(app, artifacts):
                     click.echo_via_pager(data)
 
 
+###################################################################
+#                     Artifact Delete Command                     #
+###################################################################
+@artifact.command(name='delete', short_help="Delete matching artifacts")
+@click.argument('artifacts', type=click.Path(), nargs=-1)
+@click.pass_obj
+def artifact_delete(app, artifacts):
+    '''Delete matching artifacts from the cache'''
+    from .._pipeline import PipelineSelection
+
+    with app.initialized():
+        cache = app.context.artifactcache
+
+        elements, artifacts = _classify_artifacts(artifacts, cache.cas,
+                                                  app.project.directory)
+
+        if not elements and not artifacts:
+            element = app.context.guess_element()
+            if element is not None:
+                elements = [element]
+
+        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()))
+        if artifacts:
+            for i, ref in enumerate(artifacts, start=1):
+                cache.cas.remove(ref, defer_prune=(i != len(artifacts)))
+
+
 ##################################################################
 #                      DEPRECATED Commands                       #
 ##################################################################