switch to uint64 cause native word length
This commit is contained in:
Vendored
+1
-1
@@ -16,7 +16,7 @@ const userAgent = "pacman/7.1.0 (Linux x86_64) libalpm/16.0.1"
|
|||||||
|
|
||||||
type Cache struct {
|
type Cache struct {
|
||||||
cfg CacheConfig
|
cfg CacheConfig
|
||||||
mirrorIdx atomic.Uint32
|
mirrorIdx atomic.Uint64
|
||||||
sf singleflight.Group //prevents duplicate downloads
|
sf singleflight.Group //prevents duplicate downloads
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
client http.Client
|
client http.Client
|
||||||
|
|||||||
Vendored
+2
-1
@@ -10,7 +10,8 @@ import (
|
|||||||
|
|
||||||
func (c *Cache) nextMirror() string {
|
func (c *Cache) nextMirror() string {
|
||||||
idx := c.mirrorIdx.Add(1) - 1
|
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 {
|
func downloadToDisk(url, destPath string, c http.Client) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user