fix: download client and ipt download url

This commit is contained in:
Ludvig Lundgren 2021-08-30 20:54:14 +02:00
parent 9aaf79e7bb
commit 2cba7a90e0
3 changed files with 18 additions and 5 deletions

View file

@ -1,6 +1,7 @@
package release
import (
"errors"
"fmt"
"github.com/anacrolix/torrent/metainfo"
@ -41,12 +42,17 @@ func (s *service) Process(announce domain.Announce) error {
// TODO check extra headers, cookie
res, err := c.DownloadFile(announce.TorrentUrl, nil)
if err != nil {
log.Error().Err(err).Msgf("could not download file: %v", announce.TorrentName)
log.Error().Stack().Err(err).Msgf("could not download file: %v", announce.TorrentName)
return err
}
if res.FileName == "" {
return err
return errors.New("error downloading file, no tmp file")
}
if res.Body == nil {
log.Error().Stack().Err(err).Msgf("tmp file error - empty body: %v", announce.TorrentName)
return errors.New("empty body")
}
//log.Debug().Msgf("downloaded torrent file: %v", res.FileName)
@ -68,7 +74,7 @@ func (s *service) Process(announce domain.Announce) error {
// take action (watchFolder, test, runProgram, qBittorrent, Deluge etc)
err = s.actionSvc.RunActions(res.FileName, hash, *announce.Filter, announce)
if err != nil {
log.Error().Err(err).Msgf("error running actions for filter: %v", announce.Filter.Name)
log.Error().Stack().Err(err).Msgf("error running actions for filter: %v", announce.Filter.Name)
return err
}