From de0c96152b6af0d07c937d1784eb0b2f81af5743 Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Fri, 5 Apr 2024 11:57:22 -0400 Subject: [PATCH] cmd-prune: don't prune the ostree repo if non-existant In cases where we buildfetch a bunch of different builds if we then want to clean some of them up easily with `cosa prune` it will fail if there is no ostree repo at `tmp/repo`. Let's just check and if nothing is there then let's not try to clean it up. --- src/cmd-prune | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmd-prune b/src/cmd-prune index aadd455831..660eae5790 100755 --- a/src/cmd-prune +++ b/src/cmd-prune @@ -176,7 +176,8 @@ error_during_pruning = False for build in builds_to_delete: print(f"Pruning build {build.id}") try: - subprocess.check_call(['ostree', '--repo=tmp/repo', 'refs', '--delete', build.id]) + if os.path.exists('tmp/repo'): + subprocess.check_call(['ostree', '--repo=tmp/repo', 'refs', '--delete', build.id]) rmtree(os.path.join(builds_dir, build.id)) except Exception as e: error_during_pruning = True