Remove get torrents count config and use worker pool on all places

This commit is contained in:
Ben Adrian Sarmiento
2024-06-07 19:19:18 +02:00
parent ce2a56df2e
commit db086b19b3
9 changed files with 131 additions and 57 deletions

View File

@@ -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