Use exact path for symlink source when using SymlinkDownloader

This commit is contained in:
Cucumberrbob 2025-02-02 20:58:51 +00:00 committed by Wald764
parent 303244127b
commit 56a61ad012
3 changed files with 24 additions and 1 deletions

View file

@ -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");

View file

@ -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);

View file

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