fixup! forget: return error if no policy was specified

This commit is contained in:
Michael Eischer 2024-05-19 00:08:47 +02:00
parent 1ee6255dd2
commit 857f636e5b
1 changed files with 2 additions and 2 deletions

View File

@ -258,8 +258,8 @@ func runForget(ctx context.Context, opts ForgetOptions, pruneOptions PruneOption
keep, remove, reasons := restic.ApplyPolicy(snapshotGroup, policy)
if len(keep) == 0 {
return fmt.Errorf("refusing to delete last snapshot of snapshot group %v", key)
if !policy.Empty() && len(keep) == 0 {
return fmt.Errorf("refusing to delete last snapshot of snapshot group \"%v\"", key.String())
}
if len(keep) != 0 && !gopts.Quiet && !gopts.JSON {
printer.P("keep %d snapshots:\n", len(keep))