Add bin other torrent when torrent is completed
This commit is contained in:
@@ -192,18 +192,24 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
if info != nil && info.Progress == 100 && !t.isStillBroken(info, brokenFiles) {
|
||||
// successful repair
|
||||
torrent.State.Event(context.Background(), "mark_as_repaired")
|
||||
// delete old torrents
|
||||
t.repairLog.Infof("Successfully repaired torrent %s by redownloading all files", t.GetKey(torrent))
|
||||
// delete the torrents it replaced
|
||||
torrent.DownloadedIDs.Each(func(torrentID string) bool {
|
||||
if torrentID != info.ID {
|
||||
t.setToBinImmediately(torrentID)
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
t.repairLog.Infof("Successfully repaired torrent %s by redownloading all files", t.GetKey(torrent))
|
||||
return
|
||||
} else if info != nil && info.Progress != 100 {
|
||||
t.repairLog.Infof("Torrent %s is still in progress after redownloading but it should be repaired once done", t.GetKey(torrent))
|
||||
// once info.ID is done, we can delete the old torrent
|
||||
torrent.DownloadedIDs.Each(func(torrentID string) bool {
|
||||
if torrentID != info.ID {
|
||||
t.setToBinOnceDone(fmt.Sprintf("%s-%s", info.ID, torrentID))
|
||||
}
|
||||
return false
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user