Fetch never-fetched packages instantly

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-11-29 14:55:11 +01:00
parent 8bfa77c77c
commit b824da5c1d
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D

View file

@ -92,6 +92,11 @@ func checkForUpdates(ce *database.CatalogEntry) error {
}
func nextCheckTime(ce *database.CatalogEntry, lastCheck *time.Time) time.Time {
if lastCheck == nil {
// Has never been checked, check ASAP
return time.Now()
}
hash := md5.New()
fmt.Fprint(hash, ce.Key())
@ -100,10 +105,6 @@ func nextCheckTime(ce *database.CatalogEntry, lastCheck *time.Time) time.Time {
jitter += int64(c) * int64(math.Pow(10, float64(i)))
}
if lastCheck == nil {
lastCheck = ptrTime(processStart)
}
next := lastCheck.
Truncate(cfg.CheckDistribution).
Add(time.Duration(jitter) % cfg.CheckDistribution)