Refactor workers

This commit is contained in:
Ben Sarmiento
2024-01-27 13:17:45 +01:00
parent e01622064d
commit 05d2544fe8
6 changed files with 127 additions and 171 deletions

View File

@@ -16,15 +16,18 @@ const (
EXPIRED_LINK_TOLERANCE_HOURS = 24
)
func (t *TorrentManager) RepairAll() {
func (t *TorrentManager) startRepairJob() {
if !t.Config.EnableRepair() {
t.log.Info("Repair is disabled, skipping repair job")
}
// there is 1 repair worker, with max 1 blocking task
_ = t.repairPool.Submit(func() {
t.log.Info("Periodic repair invoked; searching for broken torrents")
t.repairAll()
})
}
func (t *TorrentManager) repairAll() {
t.log.Info("Periodic repair invoked; searching for broken torrents")
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)
// collect all torrents that need to be repaired