From 268bb6826c8e9a0d57b118523aade250863064a0 Mon Sep 17 00:00:00 2001 From: Sculas Date: Sun, 5 Jan 2025 22:17:22 +0100 Subject: [PATCH] fix: Fix invalid download path with single-file torrents --- .../RdtClient.Service/Helpers/DownloadHelper.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/server/RdtClient.Service/Helpers/DownloadHelper.cs b/server/RdtClient.Service/Helpers/DownloadHelper.cs index 06724ad..609224e 100644 --- a/server/RdtClient.Service/Helpers/DownloadHelper.cs +++ b/server/RdtClient.Service/Helpers/DownloadHelper.cs @@ -43,6 +43,14 @@ public static class DownloadHelper subPath = subPath.Trim('/').Trim('\\'); torrentPath = Path.Combine(torrentPath, subPath); + } else if (torrent.Files.Count == 1) + { + if (directory != fileName) + { + throw new($"Torrent path {torrentPath} does not match file name {fileName}. This is a requirement for single file torrents."); + } + + return torrentPath; } } @@ -90,6 +98,14 @@ public static class DownloadHelper subPath = subPath.Trim('/').Trim('\\'); torrentPath = Path.Combine(torrentPath, subPath); + } else if (torrent.Files.Count == 1) + { + if (torrentPath != fileName) + { + throw new($"Torrent path {torrentPath} does not match file name {fileName}. This is a requirement for single file torrents."); + } + + return torrentPath; } }