Add bin other torrent when torrent is completed

This commit is contained in:
Ben Sarmiento
2024-05-25 15:49:57 +02:00
parent 264d62d0dc
commit b8c67a83cf
4 changed files with 146 additions and 114 deletions

View File

@@ -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
}