Log when rejecting files in TB GetDownloadLinks

This commit is contained in:
Cucumberrbob 2025-02-13 11:50:40 +00:00
parent e5e64e6946
commit 9299314b14
No known key found for this signature in database
GPG key ID: 2B935C47401C3614

View file

@ -6,6 +6,7 @@ using RdtClient.Data.Enums;
using RdtClient.Data.Models.TorrentClient; using RdtClient.Data.Models.TorrentClient;
using System.Web; using System.Web;
using RdtClient.Data.Models.Data; using RdtClient.Data.Models.Data;
using RdtClient.Service.Helpers;
namespace RdtClient.Service.Services.TorrentClients; namespace RdtClient.Service.Services.TorrentClients;
@ -289,19 +290,37 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
var selectedFiles = torrent.Files.Where(file => var selectedFiles = torrent.Files.Where(file =>
{ {
var fileName = Path.GetFileName(file.Path);
if (torrent.DownloadMinSize > 0 && file.Bytes < torrent.DownloadMinSize * 1024 * 1024) if (torrent.DownloadMinSize > 0 && file.Bytes < torrent.DownloadMinSize * 1024 * 1024)
{ {
Log($"Not downloading {fileName}, its size of {file.Bytes} bytes is smaller than the minimum size of {torrent.DownloadMinSize} bytes", torrent);
return false; return false;
} }
if (!String.IsNullOrWhiteSpace(torrent.IncludeRegex)) if (!String.IsNullOrWhiteSpace(torrent.IncludeRegex))
{ {
return !Regex.IsMatch(Path.GetFileName(file.Path), torrent.IncludeRegex); if (!Regex.IsMatch(fileName, torrent.IncludeRegex))
{
Log($"Not downloading {fileName}, it does not match regex {torrent.IncludeRegex}", torrent);
return false;
}
// If IncludeRegex is set, don't look at ExcludeRegex
return true;
} }
if (!String.IsNullOrWhiteSpace(torrent.ExcludeRegex)) if (!String.IsNullOrWhiteSpace(torrent.ExcludeRegex))
{ {
return Regex.IsMatch(Path.GetFileName(file.Path), torrent.ExcludeRegex); if (Regex.IsMatch(fileName, torrent.ExcludeRegex))
{
Log($"Not downloading {fileName}, it matches regex {torrent.ExcludeRegex}", torrent);
return false;
}
} }
return true; return true;
@ -353,4 +372,14 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
return Map(result!); return Map(result!);
} }
private void Log(String message, Torrent? torrent = null)
{
if (torrent != null)
{
message = $"{message} {torrent.ToLog()}";
}
logger.LogDebug(message);
}
} }