From a0c13af94bda48f127af2ace4db192c9f7bcacd8 Mon Sep 17 00:00:00 2001 From: Ben Adrian Sarmiento Date: Sun, 23 Jun 2024 22:30:46 +0200 Subject: [PATCH] Reorder conditions --- internal/torrent/repair.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/torrent/repair.go b/internal/torrent/repair.go index 83016e8..9cccfe5 100644 --- a/internal/torrent/repair.go +++ b/internal/torrent/repair.go @@ -525,14 +525,13 @@ func (t *TorrentManager) redownloadTorrent(torrent *Torrent, selection []string) return nil, fmt.Errorf("non-OK state: %s", info.Status) } - // check if incorrect number of links - if info.Progress == 100 && len(info.Links) != len(selection) { + if info.Progress != 100 { + t.repairLog.Infof("Downloading torrent %s (id=%s, progress=%d)", t.GetKey(torrent), info.ID, info.Progress) + } else if info.Progress == 100 && len(info.Links) == len(selection) { + t.repairLog.Infof("Downloaded %d file(s) of torrent %s (id=%s)", len(selection), t.GetKey(torrent), info.ID) + } else if info.Progress == 100 && len(info.Links) != len(selection) { t.DeleteByID(newTorrentID) return nil, fmt.Errorf("only got %d links but we need %d", len(info.Links), len(selection)) - } else if info.Progress != 100 { - t.repairLog.Infof("Downloading torrent %s (id=%s, progress=%d)", t.GetKey(torrent), info.ID, info.Progress) - } else { - t.repairLog.Infof("Downloaded %d file(s) of torrent %s (id=%s)", len(selection), t.GetKey(torrent), info.ID) } return info, nil