From f92130d878627cfaaa0042d2691b46929843807f Mon Sep 17 00:00:00 2001 From: jtagcat Date: Wed, 29 Dec 2021 01:08:29 +0200 Subject: [PATCH] logging: quiet 'removing n old cache dirs' Closes #3595 Choosing to include `stdoutIsTerminal()` as: - all other instances with `!opts.JSON` do so - this likely will not affect anything, especially when autorun - this seems to not be a meaningful enough summary to include in auto-backup reports JSON is still likely not guaranteed to work and this is a suboptimal solution to this. Ideally, #1804 should refactor all print statements, and define+document(+handle) when stdoutIsTerminal() should be used. Else, it may end up more inconsistent and bulky (duplicate lines, longer files). --- cmd/restic/global.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/restic/global.go b/cmd/restic/global.go index 942c536ff..9f42f851a 100644 --- a/cmd/restic/global.go +++ b/cmd/restic/global.go @@ -502,8 +502,9 @@ func OpenRepository(opts GlobalOptions) (*repository.Repository, error) { // cleanup old cache dirs if instructed to do so if opts.CleanupCache { - Printf("removing %d old cache dirs from %v\n", len(oldCacheDirs), c.Base) - + if stdoutIsTerminal() && !opts.JSON { + Verbosef("removing %d old cache dirs from %v\n", len(oldCacheDirs), c.Base) + } for _, item := range oldCacheDirs { dir := filepath.Join(c.Base, item.Name()) err = fs.RemoveAll(dir)