Fix repair fsm
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user