[TB] fix: calling fileFilter twice in getdllinks

This commit is contained in:
Sam Heinz 2025-03-12 22:27:33 +10:00
parent 85a0e7b04f
commit 087653e5b6

View file

@ -287,10 +287,9 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
public async Task<IList<String>?> GetDownloadLinks(Torrent torrent) public async Task<IList<String>?> GetDownloadLinks(Torrent torrent)
{ {
var torrentId = await GetClient().Torrents.GetHashInfoAsync(torrent.Hash, skipCache: true); 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 (downloadableFiles.Count == torrent.Files.Count && torrent.DownloadClient != Data.Enums.DownloadClient.Symlink)
if (allFilesDownloadable && torrent.DownloadClient != Data.Enums.DownloadClient.Symlink)
{ {
logger.LogDebug("Downloading files from TorBox as a zip."); logger.LogDebug("Downloading files from TorBox as a zip.");
return [$"https://torbox.app/fakedl/{torrentId?.Id}/zip"]; return [$"https://torbox.app/fakedl/{torrentId?.Id}/zip"];
@ -298,10 +297,7 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
else else
{ {
logger.LogDebug("Downloading files from TorBox individually."); logger.LogDebug("Downloading files from TorBox individually.");
return torrent.Files return downloadableFiles.Select(file => $"https://torbox.app/fakedl/{torrentId?.Id}/{file.Id}").ToList();
.Where(file => fileFilter.IsDownloadable(torrent, file.Path, file.Bytes))
.Select(file => $"https://torbox.app/fakedl/{torrentId?.Id}/{file.Id}")
.ToList();
} }
} }
@ -316,6 +312,7 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
using (HttpClient client = new()) using (HttpClient client = new())
{ {
client.Timeout = TimeSpan.FromSeconds(30);
var request = new HttpRequestMessage(HttpMethod.Head, uri); var request = new HttpRequestMessage(HttpMethod.Head, uri);
var response = await client.SendAsync(request); var response = await client.SendAsync(request);
if (response.Content.Headers.ContentDisposition != null) if (response.Content.Headers.ContentDisposition != null)