diff --git a/internal/cache/cache.go b/internal/cache/cache.go index 1c297ad..60b409c 100644 --- a/internal/cache/cache.go +++ b/internal/cache/cache.go @@ -16,7 +16,7 @@ const userAgent = "pacman/7.1.0 (Linux x86_64) libalpm/16.0.1" type Cache struct { cfg CacheConfig - mirrorIdx atomic.Uint32 + mirrorIdx atomic.Uint64 sf singleflight.Group //prevents duplicate downloads mu sync.Mutex client http.Client diff --git a/internal/cache/helpers.go b/internal/cache/helpers.go index 4726d1c..ccd4bde 100644 --- a/internal/cache/helpers.go +++ b/internal/cache/helpers.go @@ -10,7 +10,8 @@ import ( func (c *Cache) nextMirror() string { idx := c.mirrorIdx.Add(1) - 1 - return c.cfg.mirrorURLs[idx%uint32(len(c.cfg.mirrorURLs))] + mirrorCount := uint64(len(c.cfg.mirrorURLs)) + return c.cfg.mirrorURLs[idx%mirrorCount] } func downloadToDisk(url, destPath string, c http.Client) error {