Merge pull request #872 from middelink/fix-787

Suppress (non error) output of `forget` during -q
This commit is contained in:
Alexander Neumann 2017-03-09 21:23:36 +01:00
commit deddedd88f

View file

@ -142,19 +142,19 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
return err return err
} }
if opts.GroupByTags { if opts.GroupByTags {
Printf("snapshots for host %v, tags [%v], paths: [%v]:\n\n", key.Hostname, strings.Join(key.Tags, ", "), strings.Join(key.Paths, ", ")) Verbosef("snapshots for host %v, tags [%v], paths: [%v]:\n\n", key.Hostname, strings.Join(key.Tags, ", "), strings.Join(key.Paths, ", "))
} else { } else {
Printf("snapshots for host %v, paths: [%v]:\n\n", key.Hostname, strings.Join(key.Paths, ", ")) Verbosef("snapshots for host %v, paths: [%v]:\n\n", key.Hostname, strings.Join(key.Paths, ", "))
} }
keep, remove := restic.ApplyPolicy(snapshotGroup, policy) keep, remove := restic.ApplyPolicy(snapshotGroup, policy)
if len(keep) != 0 { if len(keep) != 0 && !gopts.Quiet {
Printf("keep %d snapshots:\n", len(keep)) Printf("keep %d snapshots:\n", len(keep))
PrintSnapshots(globalOptions.stdout, keep) PrintSnapshots(globalOptions.stdout, keep)
Printf("\n") Printf("\n")
} }
if len(remove) != 0 { if len(remove) != 0 && !gopts.Quiet {
Printf("remove %d snapshots:\n", len(remove)) Printf("remove %d snapshots:\n", len(remove))
PrintSnapshots(globalOptions.stdout, remove) PrintSnapshots(globalOptions.stdout, remove)
Printf("\n") Printf("\n")
@ -174,7 +174,7 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
} }
if removeSnapshots > 0 && opts.Prune { if removeSnapshots > 0 && opts.Prune {
Printf("%d snapshots have been removed, running prune\n", removeSnapshots) Verbosef("%d snapshots have been removed, running prune\n", removeSnapshots)
if !opts.DryRun { if !opts.DryRun {
return pruneRepository(gopts, repo) return pruneRepository(gopts, repo)
} }