diff --git a/internal/torrent/refresh.go b/internal/torrent/refresh.go index 28e8530..a6367c3 100644 --- a/internal/torrent/refresh.go +++ b/internal/torrent/refresh.go @@ -142,6 +142,20 @@ func (t *TorrentManager) refreshTorrents() []string { }) }) + t.workerPool.Submit(func() { + // update DownloadedIDs field of torrents + allTorrents.IterCb(func(accessKey string, torrent *Torrent) { + deletedIDs := torrent.DownloadedIDs.Difference(freshIDs) + if deletedIDs.Cardinality() > 0 { + deletedIDs.Each(func(id string) bool { + torrent.DownloadedIDs.Remove(id) + return false + }) + t.writeTorrentToFile(torrent) + } + }) + }) + return updatedPaths.ToSlice() } diff --git a/pkg/realdebrid/api.go b/pkg/realdebrid/api.go index 1cbae48..694dd9a 100644 --- a/pkg/realdebrid/api.go +++ b/pkg/realdebrid/api.go @@ -174,7 +174,7 @@ func (rd *RealDebrid) GetTorrents(onlyOne bool) ([]Torrent, int, error) { page := 1 // compute ceiling of totalCount / limit maxPages := (totalCount + rd.cfg.GetTorrentsCount() - 1) / rd.cfg.GetTorrentsCount() - rd.log.Debugf("Torrents total count is %d, total page count is %d", totalCount, maxPages) + rd.log.Debugf("Torrents total count is %d", totalCount) maxParallelThreads := 4 if maxPages < maxParallelThreads { maxParallelThreads = maxPages @@ -370,7 +370,7 @@ func (rd *RealDebrid) GetDownloads() []Download { // compute ceiling of totalCount / limit maxPages := (totalCount + limit - 1) / limit - rd.log.Debugf("Total downloads count is %d, total page count is %d", totalCount, maxPages) + rd.log.Debugf("Total downloads count is %d", totalCount) maxParallelThreads := 8 if maxPages < maxParallelThreads { maxParallelThreads = maxPages