fix(releases): download file follow redirects (#950)

This commit is contained in:
ze0s 2023-06-14 21:58:56 +02:00
parent 2677c16ff8
commit 1f8804154e

View file

@ -366,7 +366,7 @@ func (r *Release) DownloadTorrentFile() error {
func (r *Release) downloadTorrentFile(ctx context.Context) error { func (r *Release) downloadTorrentFile(ctx context.Context) error {
if r.HasMagnetUri() { if r.HasMagnetUri() {
return errors.New("downloading magnet links are not supported: %s", r.MagnetURI) return errors.New("downloading magnet links is not supported: %s", r.MagnetURI)
} else if r.Protocol != ReleaseProtocolTorrent { } else if r.Protocol != ReleaseProtocolTorrent {
return errors.New("could not download file: protocol %s is not supported", r.Protocol) return errors.New("could not download file: protocol %s is not supported", r.Protocol)
} }
@ -423,9 +423,9 @@ func (r *Release) downloadTorrentFile(ctx context.Context) error {
switch resp.StatusCode { switch resp.StatusCode {
case http.StatusOK: case http.StatusOK:
// Continue processing the response // Continue processing the response
case http.StatusMovedPermanently, http.StatusFound, http.StatusSeeOther, http.StatusTemporaryRedirect, http.StatusPermanentRedirect: //case http.StatusMovedPermanently, http.StatusFound, http.StatusSeeOther, http.StatusTemporaryRedirect, http.StatusPermanentRedirect:
// Handle redirect // // Handle redirect
return retry.Unrecoverable(errors.New("redirect encountered for torrent (%v) file (%v) - status code: %d - check indexer keys for %s", r.TorrentName, r.TorrentURL, resp.StatusCode, r.Indexer)) // return retry.Unrecoverable(errors.New("redirect encountered for torrent (%v) file (%v) - status code: %d - check indexer keys for %s", r.TorrentName, r.TorrentURL, resp.StatusCode, r.Indexer))
case http.StatusUnauthorized, http.StatusForbidden: case http.StatusUnauthorized, http.StatusForbidden:
return retry.Unrecoverable(errors.New("unrecoverable error downloading torrent (%v) file (%v) - status code: %d - check indexer keys for %s", r.TorrentName, r.TorrentURL, resp.StatusCode, r.Indexer)) return retry.Unrecoverable(errors.New("unrecoverable error downloading torrent (%v) file (%v) - status code: %d - check indexer keys for %s", r.TorrentName, r.TorrentURL, resp.StatusCode, r.Indexer))