mirror of
https://github.com/Luzifer/go-latestver.git
synced 2024-12-29 23:01:19 +00:00
Fetch never-fetched packages instantly
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
8bfa77c77c
commit
b824da5c1d
1 changed files with 5 additions and 4 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue