From c77edae71f558daee4bfeea095850971b4a2e6b6 Mon Sep 17 00:00:00 2001 From: Dark Dragon Date: Wed, 5 Feb 2025 22:54:25 +0100 Subject: [PATCH] prune: Remove standard output when using --json --- cmd/restic/cmd_prune.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/restic/cmd_prune.go b/cmd/restic/cmd_prune.go index 4fda7c68b..3dbb266e8 100644 --- a/cmd/restic/cmd_prune.go +++ b/cmd/restic/cmd_prune.go @@ -175,7 +175,12 @@ func runPruneWithRepo(ctx context.Context, opts PruneOptions, gopts GlobalOption Print("warning: running prune without a cache, this may be very slow!\n") } - printer := newTerminalProgressPrinter(gopts.verbosity, term) + var printer progress.Printer + if !gopts.JSON { + printer = newTerminalProgressPrinter(gopts.verbosity, term) + } else { + printer = &progress.NoopPrinter{} + } printer.P("loading indexes...\n") // loading the index before the snapshots is ok, as we use an exclusive lock here @@ -243,8 +248,8 @@ func printPruneStats(printer progress.Printer, stats repository.PruneStats) erro printer.P("this removes: %10d blobs / %s\n", stats.Blobs.Repackrm, ui.FormatBytes(stats.Size.Repackrm)) printer.P("to delete: %10d blobs / %s\n", stats.Blobs.Remove, ui.FormatBytes(stats.Size.Remove+stats.Size.Unref)) printer.P("total prune: %10d blobs / %s\n", stats.Blobs.RemoveTotal, ui.FormatBytes(stats.Size.RemoveTotal)) - if stats.Size.Uncompressed > 0 { - printer.P("not yet compressed: %s\n", ui.FormatBytes(stats.Size.Uncompressed)) + if stats.Size.Uncompressed > 0 { + printer.P("not yet compressed: %s\n", ui.FormatBytes(stats.Size.Uncompressed)) } printer.P("remaining: %10d blobs / %s\n", stats.Blobs.Remain, ui.FormatBytes(stats.Size.Remain)) printer.P("unused size after prune: %s (%s of remaining size)\n",