MCPcopy Index your code
hub / github.com/kopia/kopia / run

Method run

cli/command_content_verify.go:38–104  ·  view source on GitHub ↗
(ctx context.Context, rep repo.DirectRepository)

Source from the content-addressed store, hash-verified

36}
37
38func (c *commandContentVerify) run(ctx context.Context, rep repo.DirectRepository) error {
39 var (
40 totalCount atomic.Int32
41
42 wg sync.WaitGroup
43 )
44
45 subctx, cancel := context.WithCancel(ctx)
46
47 // ensure we cancel estimation goroutine and wait for it before returning
48 defer func() {
49 cancel()
50 wg.Wait()
51 }()
52
53 // start a goroutine that will populate totalCount
54
55 wg.Go(func() {
56 c.getTotalContentCount(subctx, rep, &totalCount)
57 })
58
59 rep.DisableIndexRefresh()
60
61 var throttle timetrack.Throttle
62
63 est := timetrack.Start()
64
65 if c.contentVerifyFull {
66 c.contentVerifyPercent = 100.0
67 }
68
69 opts := content.VerifyOptions{
70 ContentIDRange: c.contentRange.contentIDRange(),
71 ContentReadPercentage: c.contentVerifyPercent,
72 IncludeDeletedContents: c.contentVerifyIncludeDeleted,
73 ContentIterateParallelism: c.contentVerifyParallel,
74 ProgressCallbackInterval: 1,
75
76 ProgressCallback: func(vps content.VerifyProgressStats) {
77 if !throttle.ShouldOutput(c.progressInterval) {
78 return
79 }
80
81 verifiedCount := vps.SuccessCount + vps.ErrorCount
82
83 timings, ok := est.Estimate(float64(verifiedCount), float64(totalCount.Load()))
84 if ok {
85 log(ctx).Infof(" Verified %v of %v contents (%.1f%%), %v errors, remaining %v, ETA %v",
86 verifiedCount,
87 totalCount.Load(),
88 timings.PercentComplete,
89 vps.ErrorCount,
90 timings.Remaining,
91 formatTimestamp(timings.EstimatedEndTime),
92 )
93 } else {
94 log(ctx).Infof(" Verified %v contents, %v errors, estimating...", verifiedCount, vps.ErrorCount)
95 }

Callers

nothing calls this directly

Calls 11

getTotalContentCountMethod · 0.95
ShouldOutputMethod · 0.95
StartFunction · 0.92
formatTimestampFunction · 0.85
contentIDRangeMethod · 0.80
EstimateMethod · 0.80
WaitMethod · 0.65
DisableIndexRefreshMethod · 0.65
LoadMethod · 0.65
VerifyContentsMethod · 0.65
ContentReaderMethod · 0.65

Tested by

no test coverage detected