mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-15 18:46:10 +00:00
Backport of https://github.com/go-gitea/gitea/pull/38841 The test import needs `go-github/v88` here, because this branch pins v88 while main is on v89. The rest applies unchanged. --------- Co-authored-by: linnuo <3092544409@qq.com>
This commit is contained in:
@@ -152,12 +152,16 @@ func (g *GithubDownloaderV3) waitAndPickClient(ctx context.Context) {
|
||||
var recentIdx int
|
||||
var maxRemaining int
|
||||
for i := 0; i < len(g.clients); i++ {
|
||||
if g.rates[i] != nil && g.rates[i].Remaining > maxRemaining {
|
||||
if g.rates[i] == nil { // probe unknown clients once, else their rate never gets learned
|
||||
g.curClientIdx = i
|
||||
return
|
||||
}
|
||||
if g.rates[i].Remaining > maxRemaining {
|
||||
maxRemaining = g.rates[i].Remaining
|
||||
recentIdx = i
|
||||
}
|
||||
}
|
||||
g.curClientIdx = recentIdx // if no max remain, it will always pick the first client.
|
||||
g.curClientIdx = recentIdx
|
||||
|
||||
for g.rates[g.curClientIdx] != nil && g.rates[g.curClientIdx].Remaining <= GithubLimitRateRemaining {
|
||||
timer := time.NewTimer(time.Until(g.rates[g.curClientIdx].Reset.Time))
|
||||
|
||||
Reference in New Issue
Block a user