Fixes on merge behavior; remove downloads cap

This commit is contained in:
Ben Adrian Sarmiento
2024-06-04 23:58:56 +02:00
parent b0d05d27d4
commit f977abc052
5 changed files with 15 additions and 35 deletions

View File

@@ -194,6 +194,7 @@ func (rd *RealDebrid) GetTorrents(onlyOne bool) ([]Torrent, int, error) {
for i := 0; i < maxParallelThreads; i++ {
res := <-allResults
if res.err != nil {
rd.log.Warnf("Ignoring error when fetching torrents: %v", res.err)
continue
}
allTorrents = append(allTorrents, res.torrents...)
@@ -362,8 +363,6 @@ func (rd *RealDebrid) GetDownloads() []Download {
return nil
}
maxItems := rd.cfg.GetDownloadsLimit()
// reset allDownloads
allDownloads := []Download{}
page := 1
@@ -401,18 +400,15 @@ func (rd *RealDebrid) GetDownloads() []Download {
res := <-allResults
err := <-errChan
if err != nil {
return allDownloads
rd.log.Warnf("Ignoring error when fetching downloads: %v", err)
continue
}
allDownloads = append(allDownloads, res...)
}
rd.log.Debugf("Got %d/%d downloads", len(allDownloads), totalCount)
if len(allDownloads) >= totalCount || page >= maxPages || len(allDownloads) >= maxItems {
if len(allDownloads) > maxItems {
rd.log.Debugf("Capping it to %d downloads", len(allDownloads))
allDownloads = allDownloads[:maxItems]
}
if len(allDownloads) >= totalCount || page >= maxPages {
break
}