This commit is contained in:
Ben Sarmiento
2023-12-07 12:49:59 +01:00
parent caa42822ac
commit 42dce61529
3 changed files with 14 additions and 13 deletions

View File

@@ -43,6 +43,7 @@ func (t *TorrentManager) RefreshTorrents() []string {
}
freshKeys.Add(info.AccessKey)
if torrent, exists := allTorrents.Get(info.AccessKey); !exists {
t.allAccessKeys.Add(info.AccessKey)
allTorrents.Set(info.AccessKey, info)
} else if !strset.Difference(info.DownloadedIDs, torrent.DownloadedIDs).IsEmpty() {
mainTorrent := t.mergeToMain(torrent, info)
@@ -50,17 +51,10 @@ func (t *TorrentManager) RefreshTorrents() []string {
}
}
t.log.Infof("Compiled into %d torrents, %d were missing info", allTorrents.Count(), noInfoCount)
// removed
strset.Difference(t.accessKeySet, freshKeys).Each(func(accessKey string) bool {
t.accessKeySet.Remove(accessKey)
t.Delete(accessKey, false)
return true
})
// new
var updatedPaths []string
strset.Difference(freshKeys, t.accessKeySet).Each(func(accessKey string) bool {
t.accessKeySet.Add(accessKey)
// torrents yet to be assigned in a directory
strset.Difference(freshKeys, t.allAccessKeys).Each(func(accessKey string) bool {
// assign to directories
tor, _ := allTorrents.Get(accessKey)
t.assignedDirectoryCb(tor, func(directory string) {
if strings.HasPrefix(directory, "int__") {
@@ -72,6 +66,11 @@ func (t *TorrentManager) RefreshTorrents() []string {
})
return true
})
// removed torrents
strset.Difference(t.allAccessKeys, freshKeys).Each(func(accessKey string) bool {
t.Delete(accessKey, false)
return true
})
t.SetNewLatestState(t.getCurrentState())