Fix repair fsm

This commit is contained in:
Ben Sarmiento
2024-05-24 17:38:39 +02:00
parent 9ecbb5d892
commit fbd5ccbf4a
3 changed files with 48 additions and 64 deletions

View File

@@ -352,18 +352,15 @@ func (t *TorrentManager) mergeTorrents(existing, toMerge *Torrent) *Torrent {
brokenCount := 0
okCount := 0
wtfCount := 0
mergedTorrent.SelectedFiles.IterCb(func(key string, file *File) {
if file.State.Is("broken_file") {
brokenCount++
} else if file.State.Is("ok_file") {
okCount++
} else {
wtfCount++
}
})
if brokenCount == 0 && okCount > 0 && mergedTorrent.State.Can("mark_as_repaired") {
if brokenCount == 0 && okCount > 0 {
if err := mergedTorrent.State.Event(context.Background(), "mark_as_repaired"); err != nil {
t.log.Errorf("Cannot repair torrent %s: %v", t, t.GetKey(mergedTorrent), err)
}