Fix repair condition
This commit is contained in:
@@ -152,7 +152,6 @@ func (t *TorrentManager) StartRefreshJob() {
|
||||
continue
|
||||
}
|
||||
t.setNewLatestState(checksum)
|
||||
|
||||
t.refreshTorrents(false)
|
||||
t.log.Info("Finished refreshing torrents")
|
||||
case <-t.RefreshWorkerKillSwitch:
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ func NewTorrentState(initial string) *fsm.FSM {
|
||||
// when merging with another same hash torrent
|
||||
// when a torrent is rar'ed and not extracting
|
||||
{Name: "mark_as_repaired", Src: []string{"broken_torrent", "under_repair_torrent"}, Dst: "ok_torrent"},
|
||||
// when resetting repair state
|
||||
{Name: "reset_repair", Src: []string{"under_repair_torrent"}, Dst: "broken_torrent"},
|
||||
},
|
||||
fsm.Callbacks{},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user