From b8b11e8d156e85f3ea765cf62850fa6432f0e4c8 Mon Sep 17 00:00:00 2001 From: Ben Sarmiento Date: Sun, 17 Dec 2023 18:09:09 +0100 Subject: [PATCH] Torrent repair fix --- internal/torrent/repair.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/internal/torrent/repair.go b/internal/torrent/repair.go index ba1284d..0996888 100644 --- a/internal/torrent/repair.go +++ b/internal/torrent/repair.go @@ -94,6 +94,7 @@ func (t *TorrentManager) repair(torrent *Torrent) { // so we need to download 1 extra file to preserve the name // this is only relevant if we enable retain_rd_torrent_name // add the first file link encountered with a prefix of http + t.log.Debugf("Torrent %s has only 1 missing file, adding 1 extra file to preserve the name", torrent.AccessKey) for _, file := range torrent.SelectedFiles.Items() { if strings.HasPrefix(file.Link, "http") { missingFiles = append(missingFiles, *file) @@ -102,17 +103,9 @@ func (t *TorrentManager) repair(torrent *Torrent) { } } if len(missingFiles) > 0 { - t.log.Infof("Redownloading in multiple batches the %d missing files for torrent %s", len(missingFiles), torrent.AccessKey) - // if not, last resort: add only the missing files but do it in 2 batches - half := len(missingFiles) / 2 - missingFiles1 := strings.Join(getFileIDs(missingFiles[:half]), ",") - missingFiles2 := strings.Join(getFileIDs(missingFiles[half:]), ",") - if missingFiles1 != "" { - t.reinsertTorrent(torrent, missingFiles1) - } - if missingFiles2 != "" { - t.reinsertTorrent(torrent, missingFiles2) - } + t.log.Infof("Redownloading the %d missing files for torrent %s", len(missingFiles), torrent.AccessKey) + missingFileIDs := strings.Join(getFileIDs(missingFiles), ",") + t.reinsertTorrent(torrent, missingFileIDs) } else { t.log.Warnf("Torrent %s has no missing files to repair", torrent.AccessKey) }