From 56a61ad012bb36106807131c9c5000ce8ead010e Mon Sep 17 00:00:00 2001 From: Cucumberrbob <128094686+Cucumberrbob@users.noreply.github.com> Date: Sun, 2 Feb 2025 20:58:51 +0000 Subject: [PATCH] :sparkles: Use exact path for symlink source when using SymlinkDownloader --- .../Services/DownloadClient.cs | 5 +++++ .../Services/Downloaders/SymlinkDownloader.cs | 2 +- .../TorrentClients/DebridLinkTorrentClient.cs | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/server/RdtClient.Service/Services/DownloadClient.cs b/server/RdtClient.Service/Services/DownloadClient.cs index 23d0f1e..df7b05b 100644 --- a/server/RdtClient.Service/Services/DownloadClient.cs +++ b/server/RdtClient.Service/Services/DownloadClient.cs @@ -45,6 +45,11 @@ public class DownloadClient(Download download, Torrent torrent, String destinati downloadPath = AllDebridTorrentClient.GetSymlinkPath(torrent, download); } + if (torrent.ClientKind == Torrent.TorrentClientKind.DebridLink && Type == Data.Enums.DownloadClient.Symlink) + { + downloadPath = DebridLinkClient.GetSymlinkPath(torrent, download); + } + if (filePath == null || downloadPath == null) { throw new("Invalid download path"); diff --git a/server/RdtClient.Service/Services/Downloaders/SymlinkDownloader.cs b/server/RdtClient.Service/Services/Downloaders/SymlinkDownloader.cs index 74db7c0..cf91f04 100644 --- a/server/RdtClient.Service/Services/Downloaders/SymlinkDownloader.cs +++ b/server/RdtClient.Service/Services/Downloaders/SymlinkDownloader.cs @@ -62,7 +62,7 @@ public class SymlinkDownloader(String uri, String destinationPath, String path, var shouldSearch = true; // When resolving symlinks for AllDebrid, we know the exact file path, so we can skip the search. - if (clientKind == Torrent.TorrentClientKind.AllDebrid) + if (clientKind is Torrent.TorrentClientKind.AllDebrid or Torrent.TorrentClientKind.DebridLink) { var potentialFilePath = Path.Combine(rcloneMountPath, path); diff --git a/server/RdtClient.Service/Services/TorrentClients/DebridLinkTorrentClient.cs b/server/RdtClient.Service/Services/TorrentClients/DebridLinkTorrentClient.cs index 435b656..262f712 100644 --- a/server/RdtClient.Service/Services/TorrentClients/DebridLinkTorrentClient.cs +++ b/server/RdtClient.Service/Services/TorrentClients/DebridLinkTorrentClient.cs @@ -6,6 +6,8 @@ using RdtClient.Data.Models.TorrentClient; using RdtClient.Service.Helpers; using DebridLinkFrNET.Models; using System.Web; +using RdtClient.Data.Models.Data; +using Torrent = RdtClient.Data.Models.Data.Torrent; namespace RdtClient.Service.Services.TorrentClients; @@ -316,4 +318,20 @@ public class DebridLinkClient : ITorrentClient return Task.FromResult(HttpUtility.UrlDecode(uri.Segments.Last())); } + + public static String? GetSymlinkPath(Torrent torrent, Download download) + { + if (torrent.RdName == null || download.FileName == null) + { + return null; + } + + // Single file torrents always have that file at `/mnt-root/Seedbox/filename.ext` + if (torrent.Files?.Count == 1) + { + return download.FileName; + } + + return Path.Combine(torrent.RdName, download.FileName); + } } \ No newline at end of file