@@ -34,13 +34,8 @@ const (
3434// quarter of that interval, at least warmMinInterval. Refreshes stop when
3535// the cache is closed.
3636//
37- // A repository is checked at the URL its last successful refresh used, so
38- // one cached before that URL was kept waits for a client to refresh it.
3937// serves reports whether the configuration still serves a repository's
4038// directory in the cache, such as github-1a2b3c4d/acme/widgets.git.
41- //
42- // It does nothing with WarmMaxIdle 0, or StaleMaxAge under twice
43- // warmMinInterval, which includes 0.
4439func (c * Cache ) Warm (serves func (dir string ) bool ) {
4540 if ! c .warmEnabled () {
4641 return
@@ -71,22 +66,18 @@ func (c *Cache) Warm(serves func(dir string) bool) {
7166 }()
7267}
7368
74- // warmEnabled reports whether Warm checks repositories at all: not with
75- // WarmMaxIdle 0, nor when checks every half StaleMaxAge would come more
76- // often than warmMinInterval.
69+ // warmEnabled reports whether Warm checks repositories at all.
7770func (c * Cache ) warmEnabled () bool {
7871 return c .opts .WarmMaxIdle > 0 && c .warmInterval () >= warmMinInterval
7972}
8073
81- // warmInterval is how long after a check a repository is checked again in
82- // the background: half of StaleMaxAge.
74+ // warmInterval is how long after a check a repository is checked again.
8375func (c * Cache ) warmInterval () time.Duration {
8476 return c .opts .StaleMaxAge / warmStaleFraction
8577}
8678
8779// warmRetryInterval is how long after a failed check a repository is tried
88- // again in the background: a quarter of warmInterval, at least
89- // warmMinInterval.
80+ // again.
9081func (c * Cache ) warmRetryInterval () time.Duration {
9182 return max (c .warmInterval ()/ warmRetryFraction , warmMinInterval )
9283}
@@ -149,11 +140,8 @@ func (c *Cache) warmDue(now time.Time) []*repo {
149140 return due
150141}
151142
152- // warmDueLocked reports whether rp is due for a background check: cached,
153- // with a URL a refresh succeeded with, used by a client within WarmMaxIdle,
154- // not checked within warmInterval nor failed within warmRetryInterval, not
155- // refreshing, and not refused upstream or waiting after passing
156- // git.max_repo_size. c.mu must be held.
143+ // warmDueLocked reports whether rp is due for a background check. c.mu must
144+ // be held.
157145func (c * Cache ) warmDueLocked (rp * repo , now time.Time ) bool {
158146 used := rp .lastUsed .Load ()
159147 if rp .refused != nil || rp .refreshing != nil || used == 0 || rp .repoURL () == "" ||
0 commit comments