Small repairs on logic

This commit is contained in:
Ben Adrian Sarmiento
2024-06-18 19:32:56 +02:00
parent d53ba8c973
commit 34a7d6a432
8 changed files with 78 additions and 74 deletions

View File

@@ -59,7 +59,7 @@ func (rd *RealDebrid) GetTorrents(onlyOne bool) ([]Torrent, int, error) {
result := <-allResults
if result.err != nil {
rd.log.Warnf("Ignoring error when fetching torrents pg %d: %v", result.page, result.err)
continue
return nil, 0, result.err
}
bIdx := (result.page - 1) % maxParallelThreads
batches[bIdx] = []Torrent{}
@@ -71,7 +71,7 @@ func (rd *RealDebrid) GetTorrents(onlyOne bool) ([]Torrent, int, error) {
cIdxEnd := cachedCount - 1 - cIdx
for tIdx, torrent := range batch { // 250 torrents
tIdxEnd := indexFromEnd(tIdx, page+bIdx, pageSize, result.total)
if torrent.ID == cached.ID && tIdxEnd == cIdxEnd {
if torrent.ID == cached.ID && torrent.Progress == cached.Progress && tIdxEnd == cIdxEnd {
allTorrents = append(allTorrents, batch[:tIdx]...)
allTorrents = append(allTorrents, rd.torrentsCache[cIdx:]...)
rd.log.Debugf("Got %d/%d torrents", len(allTorrents), result.total)