MCPcopy
hub / github.com/kopia/kopia / run

Method run

cli/command_snapshot_verify.go:56–99  ·  view source on GitHub ↗
(ctx context.Context, rep repo.Repository)

Source from the content-addressed store, hash-verified

54}
55
56func (c *commandSnapshotVerify) run(ctx context.Context, rep repo.Repository) error {
57 if c.verifyCommandAllSources {
58 log(ctx).Error("DEPRECATED: --all-sources flag has no effect and is the default when no sources are provided.")
59 }
60
61 if dr, ok := rep.(repo.DirectRepositoryWriter); ok {
62 dr.DisableIndexRefresh()
63 }
64
65 opts := snapshotfs.VerifierOptions{
66 VerifyFilesPercent: c.verifyCommandFilesPercent,
67 FileQueueLength: c.fileQueueLength,
68 Parallelism: c.fileParallelism,
69 MaxErrors: c.verifyCommandErrorThreshold,
70 JSONStats: c.jo.jsonOutput,
71 }
72
73 if dr, ok := rep.(repo.DirectRepository); ok {
74 blobMap, err := blob.ReadBlobMap(ctx, dr.BlobReader())
75 if err != nil {
76 return errors.Wrap(err, "unable to read blob map")
77 }
78
79 opts.BlobMap = blobMap
80 }
81
82 v := snapshotfs.NewVerifier(ctx, rep, opts)
83
84 defer func() {
85 // Suppress final stats output if --json flag provided.
86 if !c.jo.jsonOutput {
87 v.ShowFinalStats(ctx)
88 }
89 }()
90
91 result, err := v.InParallel(ctx, c.makeVerifyWalkerFunc(ctx, rep, v))
92
93 if c.jo.jsonOutput {
94 c.out.printStdout("%s\n", c.jo.jsonIndentedBytes(result, " "))
95 }
96
97 //nolint:wrapcheck
98 return err
99}
100
101func (c *commandSnapshotVerify) makeVerifyWalkerFunc(ctx context.Context, rep repo.Repository, v *snapshotfs.Verifier) func(tw *snapshotfs.TreeWalker) error {
102 return func(tw *snapshotfs.TreeWalker) error {

Callers

nothing calls this directly

Calls 10

ShowFinalStatsMethod · 0.95
InParallelMethod · 0.95
makeVerifyWalkerFuncMethod · 0.95
ReadBlobMapFunction · 0.92
NewVerifierFunction · 0.92
printStdoutMethod · 0.80
jsonIndentedBytesMethod · 0.80
ErrorMethod · 0.65
DisableIndexRefreshMethod · 0.65
BlobReaderMethod · 0.65

Tested by

no test coverage detected