(ctx context.Context, rep repo.DirectRepository)
| 36 | } |
| 37 | |
| 38 | func (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 | } |
nothing calls this directly
no test coverage detected