From be6a1445037ceb324a385f5f6d896c9d75b3874b Mon Sep 17 00:00:00 2001 From: Winfried Plappert Date: Wed, 5 Mar 2025 21:44:34 +0000 Subject: [PATCH] restic diff, stats, tag - more command which vannot handle partial snapshots inserted check for partial snapshots --- cmd/restic/cmd_diff.go | 4 ++++ cmd/restic/cmd_stats.go | 8 ++++++-- cmd/restic/cmd_tag.go | 4 ++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cmd/restic/cmd_diff.go b/cmd/restic/cmd_diff.go index 35fe97fbb..c7df552ac 100644 --- a/cmd/restic/cmd_diff.go +++ b/cmd/restic/cmd_diff.go @@ -74,6 +74,10 @@ func loadSnapshot(ctx context.Context, be restic.Lister, repo restic.LoaderUnpac if err != nil { return nil, "", errors.Fatal(err.Error()) } + err = checkPartialSnapshot(sn, "fatal", "diff") + if err != nil { + return sn, "", err + } return sn, subfolder, err } diff --git a/cmd/restic/cmd_stats.go b/cmd/restic/cmd_stats.go index 1e7df11cb..59366f6f2 100644 --- a/cmd/restic/cmd_stats.go +++ b/cmd/restic/cmd_stats.go @@ -29,13 +29,13 @@ func newStatsCommand() *cobra.Command { Short: "Scan the repository and show basic statistics", Long: ` The "stats" command walks one or multiple snapshots in a repository -and accumulates statistics about the data stored therein. It reports +and accumulates statistics about the data stored therein. It reports on the number of unique files and their sizes, according to one of the counting modes as given by the --mode flag. It operates on all snapshots matching the selection criteria or all snapshots if nothing is specified. The special snapshot ID "latest" -is also supported. Some modes make more sense over +is also supported. Some modes make more sense over just a single snapshot, while others are useful across all snapshots, depending on what you are trying to calculate. @@ -130,6 +130,10 @@ func runStats(ctx context.Context, opts StatsOptions, gopts GlobalOptions, args } for sn := range FindFilteredSnapshots(ctx, snapshotLister, repo, &opts.SnapshotFilter, args) { + err = checkPartialSnapshot(sn, "fatal", "stats") + if err != nil { + return err + } err = statsWalkSnapshot(ctx, sn, repo, opts, stats) if err != nil { return fmt.Errorf("error walking snapshot: %v", err) diff --git a/cmd/restic/cmd_tag.go b/cmd/restic/cmd_tag.go index 39e9a16b5..ca5b2144f 100644 --- a/cmd/restic/cmd_tag.go +++ b/cmd/restic/cmd_tag.go @@ -157,6 +157,10 @@ func runTag(ctx context.Context, opts TagOptions, gopts GlobalOptions, term *ter } for sn := range FindFilteredSnapshots(ctx, repo, repo, &opts.SnapshotFilter, args) { + err := checkPartialSnapshot(sn, "fatal", "tag") + if err != nil { + return err + } changed, err := changeTags(ctx, repo, sn, opts.SetTags.Flatten(), opts.AddTags.Flatten(), opts.RemoveTags.Flatten(), printFunc) if err != nil { Warnf("unable to modify the tags for snapshot ID %q, ignoring: %v\n", sn.ID(), err)