From 087653e5b6e62e3011dfb8f9d9ca752d1a8a844f Mon Sep 17 00:00:00 2001 From: Sam Heinz <54530346+asylumexp@users.noreply.github.com> Date: Wed, 12 Mar 2025 22:27:33 +1000 Subject: [PATCH] [TB] fix: calling fileFilter twice in getdllinks --- .../Services/TorrentClients/TorBoxTorrentClient.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/server/RdtClient.Service/Services/TorrentClients/TorBoxTorrentClient.cs b/server/RdtClient.Service/Services/TorrentClients/TorBoxTorrentClient.cs index 64b3308..a354675 100644 --- a/server/RdtClient.Service/Services/TorrentClients/TorBoxTorrentClient.cs +++ b/server/RdtClient.Service/Services/TorrentClients/TorBoxTorrentClient.cs @@ -287,10 +287,9 @@ public class TorBoxTorrentClient(ILogger logger, IHttpClien public async Task?> GetDownloadLinks(Torrent torrent) { var torrentId = await GetClient().Torrents.GetHashInfoAsync(torrent.Hash, skipCache: true); + var downloadableFiles = torrent.Files.Where(file => fileFilter.IsDownloadable(torrent, file.Path, file.Bytes)).ToList(); - var allFilesDownloadable = torrent.Files.All(file => fileFilter.IsDownloadable(torrent, file.Path, file.Bytes)); - - if (allFilesDownloadable && torrent.DownloadClient != Data.Enums.DownloadClient.Symlink) + if (downloadableFiles.Count == torrent.Files.Count && torrent.DownloadClient != Data.Enums.DownloadClient.Symlink) { logger.LogDebug("Downloading files from TorBox as a zip."); return [$"https://torbox.app/fakedl/{torrentId?.Id}/zip"]; @@ -298,10 +297,7 @@ public class TorBoxTorrentClient(ILogger logger, IHttpClien else { logger.LogDebug("Downloading files from TorBox individually."); - return torrent.Files - .Where(file => fileFilter.IsDownloadable(torrent, file.Path, file.Bytes)) - .Select(file => $"https://torbox.app/fakedl/{torrentId?.Id}/{file.Id}") - .ToList(); + return downloadableFiles.Select(file => $"https://torbox.app/fakedl/{torrentId?.Id}/{file.Id}").ToList(); } } @@ -316,6 +312,7 @@ public class TorBoxTorrentClient(ILogger logger, IHttpClien using (HttpClient client = new()) { + client.Timeout = TimeSpan.FromSeconds(30); var request = new HttpRequestMessage(HttpMethod.Head, uri); var response = await client.SendAsync(request); if (response.Content.Headers.ContentDisposition != null)