[TB] Add default for fileName in DownloadHelper
This commit is contained in:
parent
c34c62f879
commit
dffce96a45
1 changed files with 8 additions and 1 deletions
|
|
@ -5,7 +5,7 @@ namespace RdtClient.Service.Helpers;
|
||||||
|
|
||||||
public static class DownloadHelper
|
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;
|
var fileUrl = download.Link;
|
||||||
|
|
||||||
|
|
@ -19,6 +19,13 @@ public static class DownloadHelper
|
||||||
var uri = new Uri(fileUrl);
|
var uri = new Uri(fileUrl);
|
||||||
var torrentPath = Path.Combine(downloadPath, directory);
|
var torrentPath = Path.Combine(downloadPath, directory);
|
||||||
|
|
||||||
|
if (String.IsNullOrWhiteSpace(fileName))
|
||||||
|
{
|
||||||
|
fileName = uri.Segments.Last();
|
||||||
|
|
||||||
|
fileName = HttpUtility.UrlDecode(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
fileName = FileHelper.RemoveInvalidFileNameChars(fileName);
|
fileName = FileHelper.RemoveInvalidFileNameChars(fileName);
|
||||||
|
|
||||||
var matchingTorrentFiles = torrent.Files.Where(m => m.Path.EndsWith(fileName)).Where(m => !String.IsNullOrWhiteSpace(m.Path)).ToList();
|
var matchingTorrentFiles = torrent.Files.Where(m => m.Path.EndsWith(fileName)).Where(m => !String.IsNullOrWhiteSpace(m.Path)).ToList();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue