Skip to content

Commit

Permalink
Merge pull request #651 from Sculas/fix/path-single-file-torrent
Browse files Browse the repository at this point in the history
fix: Fix invalid download path with single-file torrents
  • Loading branch information
rogerfar authored Jan 5, 2025
2 parents 79164d5 + 268bb68 commit e700939
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions server/RdtClient.Service/Helpers/DownloadHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
}
}

Expand Down

0 comments on commit e700939

Please sign in to comment.