Do not verify if fresh link
This commit is contained in:
@@ -337,10 +337,6 @@ func (r *HTTPClient) VerifyLink(link string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
timeout := time.Duration(r.timeoutSecs) * time.Second
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
req = req.WithContext(ctx)
|
||||
resp, err := r.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -107,18 +107,7 @@ func (rd *RealDebrid) UnrestrictAndVerify(link string) (*Download, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
unrestrictCache.Set(link, download)
|
||||
|
||||
rd.verifiedLinks.Remove(download.ID)
|
||||
err = rd.downloadClient.VerifyLink(download.Download)
|
||||
if utils.IsBytesLimitReached(err) {
|
||||
rd.TokenManager.SetTokenAsExpired(token, "bandwidth limit exceeded")
|
||||
continue
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rd.verifiedLinks.Set(download.ID, now+DOWNLOAD_LINK_EXPIRY)
|
||||
|
||||
return download, err
|
||||
@@ -433,7 +422,6 @@ func (rd *RealDebrid) MonitorExpiredTokens() {
|
||||
expiredTokens := rd.TokenManager.GetExpiredTokens()
|
||||
for _, token := range expiredTokens {
|
||||
unrestrictCache, _ := rd.UnrestrictCache.Get(token)
|
||||
stillExpired := true
|
||||
skipAll := false
|
||||
unrestrictCache.IterCb(func(key string, download *Download) {
|
||||
if skipAll {
|
||||
@@ -442,20 +430,19 @@ func (rd *RealDebrid) MonitorExpiredTokens() {
|
||||
err := rd.downloadClient.VerifyLink(download.Download)
|
||||
if err != nil {
|
||||
if utils.IsBytesLimitReached(err) {
|
||||
if i%15 == 0 {
|
||||
if i%10 == 0 {
|
||||
rd.log.Debugf("Token %s is still expired", utils.MaskToken(token))
|
||||
}
|
||||
// we already know that it is still expired
|
||||
skipAll = true
|
||||
}
|
||||
return
|
||||
}
|
||||
stillExpired = false
|
||||
|
||||
skipAll = true
|
||||
rd.verifiedLinks.Set(download.ID, time.Now().Unix()+DOWNLOAD_LINK_EXPIRY)
|
||||
})
|
||||
if !stillExpired {
|
||||
rd.TokenManager.SetTokenAsUnexpired(token)
|
||||
}
|
||||
})
|
||||
}
|
||||
time.Sleep(sleepPeriod)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user