new test for streaming and struct changes and additions

This commit is contained in:
2026-05-14 09:24:04 -06:00
parent 98a61e0137
commit f25d36a17e
4 changed files with 87 additions and 27 deletions
+13 -8
View File
@@ -10,19 +10,18 @@ import (
"sync"
"sync/atomic"
"time"
"golang.org/x/sync/singleflight"
)
const userAgent = "pacman/7.1.0 (Linux x86_64) libalpm/16.0.1"
type Cache struct {
cfg CacheConfig
cr *os.Root
mirrorIdx atomic.Uint64
sf singleflight.Group //prevents duplicate downloads
mu sync.Mutex
client http.Client
cfg CacheConfig
cr *os.Root
mirrorIdx atomic.Uint64
refreshMu sync.Mutex
client http.Client
inFlight map[string]*inFlight
inFlightMu sync.Mutex
}
type CacheConfig struct {
@@ -33,6 +32,11 @@ type CacheConfig struct {
ClientTimeout time.Duration
}
type inFlight struct {
done chan struct{}
err error
}
type CacheFile struct {
Reader io.ReadCloser
Size int64
@@ -71,6 +75,7 @@ func NewCache(cacheRoot string, mirrorURLs []string, mirroredRepos []string) (*C
Timeout: cfg.ClientTimeout,
Transport: transport,
},
inFlight: make(map[string]*inFlight),
}, nil
}