Ignore errors when marking torrent as repaired (also mute warnings when under repair)

This commit is contained in:
Ben Sarmiento
2024-05-24 18:00:46 +02:00
parent 6d07645361
commit 7695412b22
4 changed files with 9 additions and 18 deletions

View File

@@ -182,10 +182,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
info, err := t.redownloadTorrent(torrent, []string{}) // reinsert the whole torrent, passing empty selection
if info != nil && info.Progress == 100 && !t.isStillBroken(info, brokenFiles) {
// successful repair
if err := torrent.State.Event(context.Background(), "mark_as_repaired"); err != nil {
t.log.Errorf("Cannot repair torrent %s: %v", torrent.Hash, err)
return
}
torrent.State.Event(context.Background(), "mark_as_repaired")
// delete old torrents
torrent.DownloadedIDs.Each(func(torrentID string) bool {
if torrentID != info.ID {
@@ -202,7 +199,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
}
if err != nil {
t.log.Warnf("Cannot repair torrent %s by redownloading all files (error=%s)", t.GetKey(torrent), err.Error())
t.log.Warnf("Cannot repair torrent %s by redownloading all files (error=%v)", t.GetKey(torrent), err)
} else {
t.log.Warnf("Cannot repair torrent %s by redownloading all files", t.GetKey(torrent))
}
@@ -234,7 +231,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
batchNum++
redownloadedInfo, err := t.redownloadTorrent(torrent, group)
if err != nil {
t.log.Warnf("Cannot repair torrent %s by downloading broken files (error=%s) giving up", t.GetKey(torrent), err.Error())
t.log.Warnf("Cannot repair torrent %s by downloading broken files (error=%v) giving up", t.GetKey(torrent), err)
for _, newId := range newlyDownloadedIds {
t.setToBinImmediately(newId)
}
@@ -250,7 +247,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
if len(group) > 0 {
redownloadedInfo, err := t.redownloadTorrent(torrent, group)
if err != nil {
t.log.Warnf("Cannot repair torrent %s by downloading broken files (error=%s) giving up", t.GetKey(torrent), err.Error())
t.log.Warnf("Cannot repair torrent %s by downloading broken files (error=%v) giving up", t.GetKey(torrent), err)
for _, newId := range newlyDownloadedIds {
t.setToBinImmediately(newId)
}
@@ -353,9 +350,7 @@ func (t *TorrentManager) assignLinks(torrent *Torrent) bool {
torrent.UnassignedLinks = mapset.NewSet[string]()
t.markAsUnfixable(torrent, "rar'ed by RD")
t.markAsUnplayable(torrent, "rar'ed by RD")
if err := torrent.State.Event(context.Background(), "mark_as_repaired"); err != nil {
t.log.Errorf("Cannot repair torrent %s: %v", torrent.Hash, err)
}
torrent.State.Event(context.Background(), "mark_as_repaired")
}
return false // end repair
}