Multi-token support
This commit is contained in:
@@ -196,7 +196,7 @@ func (t *TorrentManager) repair(torrent *Torrent, wg *sync.WaitGroup) {
|
||||
if bwLimitReached || !file.State.Is("ok_file") {
|
||||
return
|
||||
}
|
||||
_, err := t.UnrestrictFile(file, true)
|
||||
_, err := t.UnrestrictFile(file)
|
||||
if dlErr, ok := err.(*http.DownloadErrorResponse); ok && dlErr.Message == "bytes_limit_reached" {
|
||||
bwLimitReached = true
|
||||
return
|
||||
@@ -339,7 +339,7 @@ func (t *TorrentManager) assignLinks(torrent *Torrent) bool {
|
||||
bwLimitReached := false
|
||||
torrent.UnassignedLinks.Clone().Each(func(link string) bool {
|
||||
// unrestrict each unassigned link that was filled out during torrent init
|
||||
unrestrict, err := t.UnrestrictLink(link, true)
|
||||
unrestrict, err := t.rd.UnrestrictLink(link)
|
||||
if dlErr, ok := err.(*http.DownloadErrorResponse); ok && dlErr.Message == "bytes_limit_reached" {
|
||||
bwLimitReached = true
|
||||
return true
|
||||
@@ -481,7 +481,7 @@ func (t *TorrentManager) redownloadTorrent(torrent *Torrent, selection []string)
|
||||
// redownload torrent
|
||||
var newTorrentID string
|
||||
prevState := t.latestState
|
||||
resp, err := t.api.AddMagnetHash(torrent.Hash)
|
||||
resp, err := t.rd.AddMagnetHash(torrent.Hash)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "timeout") {
|
||||
newState := t.getCurrentState()
|
||||
@@ -523,14 +523,14 @@ func (t *TorrentManager) redownloadTorrent(torrent *Torrent, selection []string)
|
||||
return nil, fmt.Errorf("cannot start redownloading: too many retries")
|
||||
}
|
||||
|
||||
err = t.api.SelectTorrentFiles(newTorrentID, finalSelection)
|
||||
err = t.rd.SelectTorrentFiles(newTorrentID, finalSelection)
|
||||
if err != nil {
|
||||
t.DeleteByID(newTorrentID)
|
||||
return nil, fmt.Errorf("cannot start redownloading: %v", err)
|
||||
}
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
info, err = t.api.GetTorrentInfo(newTorrentID)
|
||||
info, err = t.rd.GetTorrentInfo(newTorrentID)
|
||||
if err != nil {
|
||||
t.DeleteByID(newTorrentID)
|
||||
return nil, fmt.Errorf("cannot get info on redownloaded : %v", err)
|
||||
@@ -568,7 +568,7 @@ func (t *TorrentManager) canCapacityHandle() bool {
|
||||
const maxDelay = 60 * time.Second
|
||||
retryCount := 0
|
||||
for {
|
||||
count, err := t.api.GetActiveTorrentCount()
|
||||
count, err := t.rd.GetActiveTorrentCount()
|
||||
if err != nil {
|
||||
t.repairLog.Warnf("Cannot get active downloads count: %v", err)
|
||||
if retryCount >= maxRetries {
|
||||
@@ -679,7 +679,7 @@ func (t *TorrentManager) checkIfBroken(info *realdebrid.TorrentInfo, brokenFiles
|
||||
if oldFile.ID != newFile.ID {
|
||||
continue
|
||||
}
|
||||
if _, err := t.UnrestrictFile(selectedFiles[idx], true); err != nil {
|
||||
if _, err := t.UnrestrictFile(selectedFiles[idx]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user