Try using the file/folder structure when downloading.
This commit is contained in:
parent
71e1aae5ab
commit
a78ff95643
3 changed files with 44 additions and 11 deletions
|
|
@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
## [2.0.60] - 2024-01-21
|
||||
### Changed
|
||||
- Fixed bug where downloads could get stuck in active state while deleted.
|
||||
- Use the RD folder structure when downloading a file.
|
||||
|
||||
## [2.0.59] - 2024-01-21
|
||||
### Changed
|
||||
|
|
|
|||
|
|
@ -19,17 +19,33 @@ public static class DownloadHelper
|
|||
var uri = new Uri(fileUrl);
|
||||
var torrentPath = Path.Combine(downloadPath, directory);
|
||||
|
||||
if (!Directory.Exists(torrentPath))
|
||||
{
|
||||
Directory.CreateDirectory(torrentPath);
|
||||
}
|
||||
|
||||
var fileName = uri.Segments.Last();
|
||||
|
||||
fileName = HttpUtility.UrlDecode(fileName);
|
||||
|
||||
fileName = FileHelper.RemoveInvalidFileNameChars(fileName);
|
||||
|
||||
var matchingTorrentFiles = torrent.Files.Where(m => m.Path.EndsWith(fileName)).Where(m => !String.IsNullOrWhiteSpace(m.Path)).ToList();
|
||||
|
||||
if (matchingTorrentFiles.Any())
|
||||
{
|
||||
var matchingTorrentFile = matchingTorrentFiles[0];
|
||||
|
||||
var subPath = Path.GetDirectoryName(matchingTorrentFile.Path);
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(subPath))
|
||||
{
|
||||
subPath = subPath.Trim('/').Trim('\\');
|
||||
|
||||
torrentPath = Path.Combine(torrentPath, subPath);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Directory.Exists(torrentPath))
|
||||
{
|
||||
Directory.CreateDirectory(torrentPath);
|
||||
}
|
||||
|
||||
var filePath = Path.Combine(torrentPath, fileName);
|
||||
|
||||
return filePath;
|
||||
|
|
@ -46,11 +62,6 @@ public static class DownloadHelper
|
|||
|
||||
var uri = new Uri(fileUrl);
|
||||
var torrentPath = RemoveInvalidPathChars(torrent.RdName);
|
||||
|
||||
if (!Directory.Exists(torrentPath))
|
||||
{
|
||||
Directory.CreateDirectory(torrentPath);
|
||||
}
|
||||
|
||||
var fileName = uri.Segments.Last();
|
||||
|
||||
|
|
@ -58,6 +69,27 @@ public static class DownloadHelper
|
|||
|
||||
fileName = FileHelper.RemoveInvalidFileNameChars(fileName);
|
||||
|
||||
var matchingTorrentFiles = torrent.Files.Where(m => m.Path.EndsWith(fileName)).Where(m => !String.IsNullOrWhiteSpace(m.Path)).ToList();
|
||||
|
||||
if (matchingTorrentFiles.Any())
|
||||
{
|
||||
var matchingTorrentFile = matchingTorrentFiles[0];
|
||||
|
||||
var subPath = Path.GetDirectoryName(matchingTorrentFile.Path);
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(subPath))
|
||||
{
|
||||
subPath = subPath.Trim('/').Trim('\\');
|
||||
|
||||
torrentPath = Path.Combine(torrentPath, subPath);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Directory.Exists(torrentPath))
|
||||
{
|
||||
Directory.CreateDirectory(torrentPath);
|
||||
}
|
||||
|
||||
var filePath = Path.Combine(torrentPath, fileName);
|
||||
|
||||
return filePath;
|
||||
|
|
|
|||
|
|
@ -384,7 +384,7 @@ public class TorrentRunner
|
|||
Log($"Setting download path to {downloadPath}", download, torrent);
|
||||
|
||||
// Start the download process
|
||||
var downloadClient = new DownloadClient(_loggerFactory, download, torrent, downloadPath);
|
||||
var downloadClient = new DownloadClient(download, torrent, downloadPath);
|
||||
|
||||
Log($"Starting download", download, torrent);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue