Fix for invalid_download_code

This commit is contained in:
Ben Adrian Sarmiento
2024-06-30 23:29:29 +02:00
parent bf193a2656
commit f3d6230935
5 changed files with 46 additions and 20 deletions

View File

@@ -276,11 +276,14 @@ func (r *HTTPClient) shouldRetry(req *http.Request, resp *http.Response, err err
return -1 // don't retry
}
} else if downloadErr, ok := err.(*DownloadErrorResponse); ok {
switch downloadErr.Code {
case http.StatusServiceUnavailable: // Service unavailable
switch downloadErr.Message {
case "bytes_limit_reached": // 503
return -1
default:
case "invalid_download_code": // 404
time.Sleep(time.Duration(rateLimitSleep) * time.Second)
return 1
default:
return 1 // retry
}
}
if err != nil && strings.Contains(err.Error(), "timeout") {