(ctx context.Context, rep repo.Repository)
| 54 | } |
| 55 | |
| 56 | func (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 | |
| 101 | func (c *commandSnapshotVerify) makeVerifyWalkerFunc(ctx context.Context, rep repo.Repository, v *snapshotfs.Verifier) func(tw *snapshotfs.TreeWalker) error { |
| 102 | return func(tw *snapshotfs.TreeWalker) error { |
nothing calls this directly
no test coverage detected