Rename variables for easy reference

This commit is contained in:
Ben Adrian Sarmiento
2024-07-21 02:11:32 +02:00
parent 47751320f7
commit f8b9f8955b
8 changed files with 46 additions and 33 deletions

View File

@@ -29,8 +29,8 @@ func (t *TorrentManager) refreshTorrents(initialRun bool) {
var wg sync.WaitGroup
var mergeChan = make(chan *Torrent, len(instances))
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)
oldKeys := mapset.NewSet[string](allTorrents.Keys()...)
torrents, _ := t.DirectoryMap.Get(INT_ALL)
oldKeys := mapset.NewSet[string](torrents.Keys()...)
freshIDs := mapset.NewSet[string]()
freshAccessKeys := mapset.NewSet[string]()
@@ -60,9 +60,9 @@ func (t *TorrentManager) refreshTorrents(initialRun bool) {
freshAccessKeys.Add(accessKey)
var forMerging *Torrent
mainTorrent, exists := allTorrents.Get(accessKey)
mainTorrent, exists := torrents.Get(accessKey)
if !exists {
allTorrents.Set(accessKey, torrent)
torrents.Set(accessKey, torrent)
t.writeTorrentToFile(torrent)
t.assignDirectory(torrent, !initialRun, true)
} else if !mainTorrent.DownloadedIDs.ContainsOne(tInfo.ID) {
@@ -83,13 +83,13 @@ func (t *TorrentManager) refreshTorrents(initialRun bool) {
continue
}
accessKey := t.GetKey(torrent)
existing, ok := allTorrents.Get(accessKey)
existing, ok := torrents.Get(accessKey)
if !ok {
t.log.Warnf("Cannot merge %s", accessKey)
continue
}
mainTorrent := t.mergeTorrents(existing, torrent)
allTorrents.Set(accessKey, mainTorrent)
torrents.Set(accessKey, mainTorrent)
t.writeTorrentToFile(mainTorrent)
t.assignDirectory(mainTorrent, !initialRun, true)
}
@@ -100,7 +100,7 @@ func (t *TorrentManager) refreshTorrents(initialRun bool) {
return
}
freshAccessKeys.Difference(oldKeys).Each(func(accessKey string) bool {
torrent, _ := allTorrents.Get(accessKey)
torrent, _ := torrents.Get(accessKey)
t.applyMediaInfoDetails(torrent)
return false
})
@@ -112,7 +112,7 @@ func (t *TorrentManager) refreshTorrents(initialRun bool) {
return false
})
t.log.Infof("Compiled into %d unique torrents", allTorrents.Count())
t.log.Infof("Compiled into %d unique torrents", torrents.Count())
t.workerPool.Submit(func() {
t.OnceDoneBin.Clone().Each(func(entry string) bool {
@@ -140,7 +140,7 @@ func (t *TorrentManager) refreshTorrents(initialRun bool) {
// cleans up DownloadedIDs field of all torrents
t.workerPool.Submit(func() {
allTorrents.IterCb(func(accessKey string, torrent *Torrent) {
torrents.IterCb(func(accessKey string, torrent *Torrent) {
deletedIDs := torrent.DownloadedIDs.Difference(freshIDs)
if deletedIDs.Cardinality() > 0 {
deletedIDs.Each(func(id string) bool {
@@ -397,8 +397,8 @@ func (t *TorrentManager) assignDirectory(tor *Torrent, triggerHook bool, outputL
for _, directories := range configV1.GetGroupMap() {
for _, directory := range directories {
if t.Config.MeetsConditions(directory, t.GetKey(tor), tor.ComputeTotalSize(), torrentIDs, filenames, fileSizes, mediaInfos) {
listing, _ := t.DirectoryMap.Get(directory)
listing.Set(accessKey, tor)
torrents, _ := t.DirectoryMap.Get(directory)
torrents.Set(accessKey, tor)
if directory != config.ALL_TORRENTS {
dirs = append(dirs, directory)