Remove get torrents count config and use worker pool on all places
This commit is contained in:
@@ -355,7 +355,7 @@ func (t *TorrentManager) mountNewDownloads() {
|
||||
}
|
||||
|
||||
func (t *TorrentManager) StartDownloadsJob() {
|
||||
_ = t.workerPool.Submit(func() {
|
||||
t.workerPool.Submit(func() {
|
||||
remountTicker := time.NewTicker(time.Duration(t.Config.GetDownloadsEveryMins()) * time.Minute)
|
||||
defer remountTicker.Stop()
|
||||
|
||||
@@ -414,7 +414,7 @@ func copyFile(sourcePath, destPath string) error {
|
||||
}
|
||||
|
||||
func (t *TorrentManager) StartDumpJob() {
|
||||
_ = t.workerPool.Submit(func() {
|
||||
t.workerPool.Submit(func() {
|
||||
dumpTicker := time.NewTicker(time.Duration(t.Config.GetDumpTorrentsEveryMins()) * time.Minute)
|
||||
defer dumpTicker.Stop()
|
||||
|
||||
@@ -444,7 +444,7 @@ func (t *TorrentManager) analyzeAllTorrents() {
|
||||
}
|
||||
|
||||
func (t *TorrentManager) StartMediaAnalysisJob() {
|
||||
_ = t.workerPool.Submit(func() {
|
||||
t.workerPool.Submit(func() {
|
||||
for range t.AnalyzeTrigger {
|
||||
t.analyzeAllTorrents()
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ func (t *TorrentManager) refreshTorrents(initialRun bool) {
|
||||
freshIDs.Add(instances[i].ID)
|
||||
wg.Add(1)
|
||||
idx := i
|
||||
_ = t.workerPool.Submit(func() {
|
||||
t.workerPool.Submit(func() {
|
||||
defer wg.Done()
|
||||
if t.binImmediately(instances[idx].ID) ||
|
||||
t.binOnceDoneErrorCheck(instances[idx].ID, instances[idx].Status) ||
|
||||
@@ -136,7 +136,7 @@ func (t *TorrentManager) refreshTorrents(initialRun bool) {
|
||||
|
||||
// StartRefreshJob periodically refreshes the torrents
|
||||
func (t *TorrentManager) StartRefreshJob() {
|
||||
go func() {
|
||||
t.workerPool.Submit(func() {
|
||||
t.log.Debug("Starting periodic refresh job")
|
||||
refreshTicker := time.NewTicker(time.Duration(t.Config.GetRefreshEverySecs()) * time.Second)
|
||||
defer refreshTicker.Stop()
|
||||
@@ -157,7 +157,7 @@ func (t *TorrentManager) StartRefreshJob() {
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *realdebrid.TorrentInfo {
|
||||
|
||||
@@ -27,7 +27,7 @@ func (t *TorrentManager) StartRepairJob() {
|
||||
t.repairTrigger = make(chan *Torrent)
|
||||
t.repairQueue = mapset.NewSet[*Torrent]()
|
||||
// there is 1 repair worker, with max 1 blocking task
|
||||
go func() {
|
||||
t.workerPool.Submit(func() {
|
||||
t.repairLog.Debug("Starting periodic repair job")
|
||||
repairTicker := time.NewTicker(time.Duration(t.Config.GetRepairEveryMins()) * time.Minute)
|
||||
defer repairTicker.Stop()
|
||||
@@ -44,7 +44,7 @@ func (t *TorrentManager) StartRepairJob() {
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
func (t *TorrentManager) invokeRepair(torrent *Torrent) {
|
||||
@@ -106,7 +106,7 @@ func (t *TorrentManager) repairAll(torrent *Torrent) {
|
||||
var wg sync.WaitGroup
|
||||
haystack.IterCb(func(_ string, torrent *Torrent) {
|
||||
wg.Add(1)
|
||||
_ = t.workerPool.Submit(func() {
|
||||
t.workerPool.Submit(func() {
|
||||
defer wg.Done()
|
||||
if torrent.UnrepairableReason != "" {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user