Merge pull request #651 from Sculas/fix/path-single-file-torrent

fix: Fix invalid download path with single-file torrents
This commit is contained in:
Roger Far 2025-01-05 15:21:05 -07:00 committed by GitHub
commit e700939cfa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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