Fix logic of fetching torrents
This commit is contained in:
@@ -356,7 +356,7 @@ func (t *TorrentManager) redownloadTorrent(torrent *Torrent, selection string) (
|
||||
}
|
||||
|
||||
// redownload torrent
|
||||
resp, err := t.Api.AddMagnetHash(torrent.Hash)
|
||||
resp, err := t.api.AddMagnetHash(torrent.Hash)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "infringing") {
|
||||
t.markAsUnfixable(torrent, "infringing torrent")
|
||||
@@ -382,7 +382,7 @@ func (t *TorrentManager) redownloadTorrent(torrent *Torrent, selection string) (
|
||||
var info *realdebrid.TorrentInfo
|
||||
for {
|
||||
// select files
|
||||
err = t.Api.SelectTorrentFiles(newTorrentID, selection)
|
||||
err = t.api.SelectTorrentFiles(newTorrentID, selection)
|
||||
if err != nil {
|
||||
t.registerFixer(newTorrentID, "download_failed")
|
||||
return nil, fmt.Errorf("cannot start redownloading: %v", err)
|
||||
@@ -391,7 +391,7 @@ func (t *TorrentManager) redownloadTorrent(torrent *Torrent, selection string) (
|
||||
time.Sleep(10 * time.Second)
|
||||
|
||||
// see if the torrent is ready
|
||||
info, err = t.Api.GetTorrentInfo(newTorrentID)
|
||||
info, err = t.api.GetTorrentInfo(newTorrentID)
|
||||
if err != nil {
|
||||
t.registerFixer(newTorrentID, "download_failed")
|
||||
return nil, fmt.Errorf("cannot get info on redownloaded torrent %s (id=%s) : %v", t.GetKey(torrent), newTorrentID, err)
|
||||
@@ -440,7 +440,7 @@ func (t *TorrentManager) canCapacityHandle() bool {
|
||||
const maxDelay = 60 * time.Second
|
||||
retryCount := 0
|
||||
for {
|
||||
count, err := t.Api.GetActiveTorrentCount()
|
||||
count, err := t.api.GetActiveTorrentCount()
|
||||
if err != nil {
|
||||
t.log.Warnf("Cannot get active downloads count: %v", err)
|
||||
if retryCount >= maxRetries {
|
||||
|
||||
Reference in New Issue
Block a user