(ctx context.Context, scanFn func())
| 270 | } |
| 271 | |
| 272 | func (h *Handler) rateLimitedScan(ctx context.Context, scanFn func()) { |
| 273 | h.mu.Lock() |
| 274 | elapsed := h.clock.Since(h.lastScanAt) |
| 275 | if elapsed < scanCooldown { |
| 276 | h.mu.Unlock() |
| 277 | |
| 278 | // Wait for cooldown then scan. |
| 279 | remaining := scanCooldown - elapsed |
| 280 | timer := h.clock.NewTimer(remaining) |
| 281 | defer timer.Stop() |
| 282 | select { |
| 283 | case <-ctx.Done(): |
| 284 | return |
| 285 | case <-timer.C: |
| 286 | } |
| 287 | |
| 288 | scanFn() |
| 289 | return |
| 290 | } |
| 291 | h.mu.Unlock() |
| 292 | scanFn() |
| 293 | } |
| 294 | |
| 295 | // isRepoDeleted returns true when the repo root directory or its .git |
| 296 | // entry no longer represents a valid git repository. This |
no test coverage detected