Merge even if in progress

This commit is contained in:
Ben Sarmiento
2024-02-07 11:23:53 +01:00
parent f42aad3c33
commit d1b4158c96

View File

@@ -45,13 +45,18 @@ func (t *TorrentManager) refreshTorrents(isInitialRun bool) []string {
continue continue
} }
accessKey := t.GetKey(info) accessKey := t.GetKey(info)
if !info.AnyInProgress() { if !info.AnyInProgress() { // since it's single instance info, Any == All
newlyFetchedKeys.Add(accessKey) newlyFetchedKeys.Add(accessKey)
} }
if torrent, exists := allTorrents.Get(accessKey); !exists { torrent, exists := allTorrents.Get(accessKey)
if !exists {
allTorrents.Set(accessKey, info) allTorrents.Set(accessKey, info)
} else if !info.DownloadedIDs.Difference(torrent.DownloadedIDs).IsEmpty() { continue
}
newIDs := info.DownloadedIDs.Union(info.InProgressIDs)
oldIDs := torrent.DownloadedIDs.Union(torrent.InProgressIDs)
if !newIDs.Difference(oldIDs).IsEmpty() {
mainTorrent := t.mergeToMain(torrent, info) mainTorrent := t.mergeToMain(torrent, info)
allTorrents.Set(accessKey, &mainTorrent) allTorrents.Set(accessKey, &mainTorrent)
} }