From b5c371892babc8306ecd3a0837d7f021d3f5f6d5 Mon Sep 17 00:00:00 2001 From: Winfried Plappert Date: Sun, 16 Feb 2025 08:38:52 +0000 Subject: [PATCH] check: harmonize my branch with master - integrate checkSummary based on the change in runCheck return values the following functions have been afftected cmd/restic/cmd_check_integration_test.go cmd/restic/cmd_migrate.go cmd/restic/cmd_prune_integration_test.go cmd/restic/integration_test.go check - corrected rebase error by not removing obsolete code. the check for the filter if len(args) > 0 { ... } is obsolete and has been replaced by if len(args) > 0 || !opts.SnapshotFilter.Empty() { ... } --- cmd/restic/cmd_check.go | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/cmd/restic/cmd_check.go b/cmd/restic/cmd_check.go index 5018a05a2..b5d971f06 100644 --- a/cmd/restic/cmd_check.go +++ b/cmd/restic/cmd_check.go @@ -249,7 +249,7 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args if len(args) > 0 || !opts.SnapshotFilter.Empty() { snapshotLister, err := restic.MemorizeList(ctx, repo, restic.SnapshotFile) if err != nil { - return err + return summary, err } err = (&opts.SnapshotFilter).FindAll(ctx, snapshotLister, repo, args, func(_ string, sn *restic.Snapshot, err error) error { @@ -262,10 +262,10 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args }) if err != nil { - return err + return summary, err } if len(selectedTrees) == 0 { - return errors.Fatal("snapshotfilter active but no snapshot selected.") + return summary, errors.Fatal("snapshotfilter active but no snapshot selected.") } } @@ -282,21 +282,6 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args return summary, ctx.Err() } - if len(args) > 0 { - snapshotLister, err := restic.MemorizeList(ctx, repo, restic.SnapshotFile) - if err != nil { - return summary, err - } - - // run down the tree, take note of the data packfiles involved - for sn := range FindFilteredSnapshots(ctx, snapshotLister, repo, &opts.SnapshotFilter, args) { - err := chkr.FindDataPackfiles(ctx, repo, sn) - if err != nil { - return summary, err - } - } - } - errorsFound := false for _, hint := range hints { switch hint.(type) { @@ -417,7 +402,7 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args if len(selectedTrees) > 0 { err = chkr.CheckWithSnapshots(ctx, selectedTrees) if err != nil { - return err + return summary, err } filterBySnapshot = true }