fix: handle file download failure (#132)

* fix: handle file download error

* fix: return error on fail to download
This commit is contained in:
Ludvig Lundgren 2022-02-09 20:09:57 +01:00 committed by GitHub
parent c25ba31a70
commit bcc9fad509
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -631,7 +631,7 @@ func (r *Release) DownloadTorrentFile(opts map[string]string) (*DownloadTorrentF
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
log.Error().Stack().Err(err).Msgf("error downloading file from: %v - bad status: %d", r.TorrentURL, resp.StatusCode) log.Error().Stack().Err(err).Msgf("error downloading file from: %v - bad status: %d", r.TorrentURL, resp.StatusCode)
return nil, err return nil, fmt.Errorf("error downloading torrent (%v) file (%v) from '%v' - status code: %d", r.TorrentName, r.TorrentURL, r.Indexer, resp.StatusCode)
} }
// Create tmp file // Create tmp file

View file

@ -247,7 +247,7 @@ func (s *service) FindAndCheckFilters(release *domain.Release) (bool, *domain.Fi
torrentFileRes, err = release.DownloadTorrentFile(nil) torrentFileRes, err = release.DownloadTorrentFile(nil)
if err != nil { if err != nil {
log.Error().Stack().Err(err).Msgf("filter-service.find_and_check_filters: (%v) could not download torrent file with id: '%v' from: %v", f.Name, release.TorrentID, release.Indexer) log.Error().Stack().Err(err).Msgf("filter-service.find_and_check_filters: (%v) could not download torrent file with id: '%v' from: %v", f.Name, release.TorrentID, release.Indexer)
continue return false, nil, err
} }
// parse torrent metainfo // parse torrent metainfo