forget: add feature flag for safe --keep-tags behavior

This commit is contained in:
Michael Eischer
2024-05-24 20:41:19 +02:00
parent 7948912b31
commit 3cc6827f09
3 changed files with 8 additions and 1 deletions
+2 -1
View File
@@ -8,6 +8,7 @@ import (
"strconv"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/feature"
"github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/ui/termstatus"
"github.com/spf13/cobra"
@@ -258,7 +259,7 @@ func runForget(ctx context.Context, opts ForgetOptions, pruneOptions PruneOption
keep, remove, reasons := restic.ApplyPolicy(snapshotGroup, policy)
if !policy.Empty() && len(keep) == 0 {
if feature.Flag.Enabled(feature.SafeForgetKeepTags) && !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 {