fix: Fix invalid download path with single-file torrents

This commit is contained in:
Sculas 2025-01-05 22:17:22 +01:00
parent 0026541dca
commit 268bb6826c
No known key found for this signature in database
GPG key ID: 1530BFF96D1EEB89

View file

@ -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;
}
}