Track deletes within refresh

This commit is contained in:
Ben Sarmiento
2024-05-21 03:01:42 +02:00
parent 2c5e7a1db0
commit 57df90620e
2 changed files with 4 additions and 7 deletions

View File

@@ -39,7 +39,6 @@ type TorrentManager struct {
RemountTrigger chan struct{}
latestState *LibraryState
allAccessKeys mapset.Set[string]
fixers cmap.ConcurrentMap[string, string] // trigger -> [command, id]
repairTrigger chan *Torrent
@@ -70,7 +69,6 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, w
RemountTrigger: make(chan struct{}, 1),
latestState: &LibraryState{},
allAccessKeys: mapset.NewSet[string](), // this is for tracking what is deleted
}
t.fixers = t.readFixersFromFile()

View File

@@ -80,12 +80,11 @@ func (t *TorrentManager) refreshTorrents(isInitialRun bool) []string {
}
}
// removed torrents
t.allAccessKeys.Difference(freshAccessKeys).Each(func(accessKey string) bool {
allAccessKeys := mapset.NewSet[string](allTorrents.Keys()...)
allAccessKeys.Difference(freshAccessKeys).Each(func(accessKey string) bool {
t.Delete(accessKey, false)
t.allAccessKeys.Remove(accessKey)
return false
})
t.allAccessKeys.Append(freshAccessKeys.ToSlice()...)
t.log.Infof("Compiled into %d torrents, %d were missing info", allTorrents.Count(), noInfoCount)