Fix repair condition

This commit is contained in:
Ben Adrian Sarmiento
2024-06-19 13:11:50 +02:00
parent 7e54d6c441
commit bd8c6c9932
8 changed files with 90 additions and 58 deletions

View File

@@ -124,7 +124,7 @@ func (t *TorrentManager) executeRepairJob(torrent *Torrent) {
t.workerPool.Submit(func() {
defer wg.Done()
canExtract := t.Config.GetRarAction() == "extract" && strings.Contains(torrent.UnrepairableReason, "rar")
if !canExtract || torrent.UnrepairableReason != "" {
if torrent.UnrepairableReason != "" && !canExtract {
return
}
// check 1: for broken files
@@ -640,3 +640,17 @@ func (t *TorrentManager) isStillBroken(info *realdebrid.TorrentInfo, brokenFiles
}
return false
}
func (t *TorrentManager) ResetRepairState() {
if !t.Config.EnableRepair() {
return
}
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)
allTorrents.IterCb(func(_ string, torrent *Torrent) {
err := torrent.State.Event(context.Background(), "reset_repair")
if err == nil {
t.repairLog.Debugf("Repair state of torrent %s has been reset", t.GetKey(torrent))
t.writeTorrentToFile(torrent)
}
})
}