From d1d45109744d26b0641977c0def31c55d5a05ef0 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 22 Oct 2023 16:40:27 +0200 Subject: [PATCH] repair packs: Add stub feature flag implementation --- cmd/restic/cmd_check.go | 2 +- cmd/restic/cmd_repair_packs.go | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/restic/cmd_check.go b/cmd/restic/cmd_check.go index c637ce89c..fd512c7e7 100644 --- a/cmd/restic/cmd_check.go +++ b/cmd/restic/cmd_check.go @@ -349,7 +349,7 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args for _, id := range salvagePacks { strIds = append(strIds, id.String()) } - Warnf("restic repair packs %v\nrestic repair snapshots --forget\n\n", strings.Join(strIds, " ")) + Warnf("RESTIC_FEATURES=repair-packs-v1 restic repair packs %v\nrestic repair snapshots --forget\n\n", strings.Join(strIds, " ")) Warnf("Corrupted blobs are either caused by hardware problems or bugs in restic. Please open an issue at https://github.com/restic/restic/issues/new/choose for further troubleshooting!\n") } } diff --git a/cmd/restic/cmd_repair_packs.go b/cmd/restic/cmd_repair_packs.go index 503e92d69..aadfe73be 100644 --- a/cmd/restic/cmd_repair_packs.go +++ b/cmd/restic/cmd_repair_packs.go @@ -36,9 +36,14 @@ func init() { cmdRepair.AddCommand(cmdRepairPacks) } -// FIXME feature flag - func runRepairPacks(ctx context.Context, gopts GlobalOptions, args []string) error { + // FIXME discuss and add proper feature flag mechanism + flag, _ := os.LookupEnv("RESTIC_FEATURES") + if flag != "repair-packs-v1" { + return errors.Fatal("This command is experimental and may change/be removed without notice between restic versions. " + + "Set the environment variable 'RESTIC_FEATURES=repair-packs-v1' to enable it.") + } + ids := restic.NewIDSet() for _, arg := range args { id, err := restic.ParseID(arg)