Pass by value not by ref

This commit is contained in:
Ben Sarmiento
2023-11-28 03:45:28 +01:00
parent 8f33cad025
commit 00c7e04795

View File

@@ -82,9 +82,9 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, p
t.log.Fatalf("Cannot get downloads: %v\n", err) t.log.Fatalf("Cannot get downloads: %v\n", err)
} }
t.DownloadCache = cmap.New[*realdebrid.Download]() t.DownloadCache = cmap.New[*realdebrid.Download]()
for _, download := range downloads { for i := range downloads {
if !t.DownloadCache.Has(download.Link) { if !t.DownloadCache.Has(downloads[i].Link) {
t.DownloadCache.Set(download.Link, &download) t.DownloadCache.Set(downloads[i].Link, &downloads[i])
} }
} }
}() }()
@@ -101,6 +101,8 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, p
initWait.Wait() initWait.Wait()
t.log.Infof("Fetched %d downloads", t.DownloadCache.Count())
torrentsChan := make(chan *Torrent, len(newTorrents)) torrentsChan := make(chan *Torrent, len(newTorrents))
var wg sync.WaitGroup var wg sync.WaitGroup
for i := range newTorrents { for i := range newTorrents {
@@ -551,7 +553,7 @@ func (t *TorrentManager) organizeChaos(links []string, selectedFiles []*File) ([
} }
resp := t.Api.UnrestrictUntilOk(link, t.cfg.ShouldServeFromRclone()) resp := t.Api.UnrestrictUntilOk(link, t.cfg.ShouldServeFromRclone())
resultsChan <- Result{Response: resp} resultsChan <- Result{Response: resp}
time.Sleep(1 * time.Second) time.Sleep(time.Duration(t.cfg.GetReleaseUnrestrictAfterMs()) * time.Millisecond)
}) })
} }