From dffce96a4514a92887c577fc661fca30af2ab82e Mon Sep 17 00:00:00 2001 From: Sam Heinz <54530346+asylumexp@users.noreply.github.com> Date: Tue, 10 Dec 2024 15:25:30 +1000 Subject: [PATCH] [TB] Add default for fileName in DownloadHelper --- server/RdtClient.Service/Helpers/DownloadHelper.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/RdtClient.Service/Helpers/DownloadHelper.cs b/server/RdtClient.Service/Helpers/DownloadHelper.cs index 02d26f0..a4cec3a 100644 --- a/server/RdtClient.Service/Helpers/DownloadHelper.cs +++ b/server/RdtClient.Service/Helpers/DownloadHelper.cs @@ -5,7 +5,7 @@ namespace RdtClient.Service.Helpers; public static class DownloadHelper { - public static String? GetDownloadPath(String downloadPath, Torrent torrent, Download download, String? fileName) + public static String? GetDownloadPath(String downloadPath, Torrent torrent, Download download, String? fileName = null) { var fileUrl = download.Link; @@ -19,6 +19,13 @@ public static class DownloadHelper var uri = new Uri(fileUrl); var torrentPath = Path.Combine(downloadPath, directory); + if (String.IsNullOrWhiteSpace(fileName)) + { + fileName = uri.Segments.Last(); + + fileName = HttpUtility.UrlDecode(fileName); + } + fileName = FileHelper.RemoveInvalidFileNameChars(fileName); var matchingTorrentFiles = torrent.Files.Where(m => m.Path.EndsWith(fileName)).Where(m => !String.IsNullOrWhiteSpace(m.Path)).ToList();