diff --git a/server/RdtClient.Data/Data/TorrentData.cs b/server/RdtClient.Data/Data/TorrentData.cs index 2355246..5ec7f67 100644 --- a/server/RdtClient.Data/Data/TorrentData.cs +++ b/server/RdtClient.Data/Data/TorrentData.cs @@ -46,14 +46,6 @@ namespace RdtClient.Data.Data .ToListAsync(); } - foreach (var torrent in _torrentCache) - { - foreach (var download in torrent.Downloads) - { - download.Torrent = null; - } - } - return _torrentCache.OrderByDescending(m => m.Added).ToList(); } finally diff --git a/server/RdtClient.Service/Services/DownloadClient.cs b/server/RdtClient.Service/Services/DownloadClient.cs index 80a88a0..879e4d2 100644 --- a/server/RdtClient.Service/Services/DownloadClient.cs +++ b/server/RdtClient.Service/Services/DownloadClient.cs @@ -21,11 +21,11 @@ namespace RdtClient.Service.Services private DownloadService _downloader; private SimpleDownloader _simpleDownloader; - public DownloadClient(Download download, String destinationPath) + public DownloadClient(Download download, Torrent torrent, String destinationPath) { _download = download; + _torrent = torrent; _destinationPath = destinationPath; - _torrent = download.Torrent; } public Boolean Finished { get; private set; } diff --git a/server/RdtClient.Service/Services/Settings.cs b/server/RdtClient.Service/Services/Settings.cs index 0d5e8e7..9f58cef 100644 --- a/server/RdtClient.Service/Services/Settings.cs +++ b/server/RdtClient.Service/Services/Settings.cs @@ -109,7 +109,7 @@ namespace RdtClient.Service.Services } }; - var downloadClient = new DownloadClient(download, downloadPath); + var downloadClient = new DownloadClient(download, download.Torrent, downloadPath); await downloadClient.Start(settings); diff --git a/server/RdtClient.Service/Services/TorrentRunner.cs b/server/RdtClient.Service/Services/TorrentRunner.cs index 2f43a08..8bf8936 100644 --- a/server/RdtClient.Service/Services/TorrentRunner.cs +++ b/server/RdtClient.Service/Services/TorrentRunner.cs @@ -253,7 +253,7 @@ namespace RdtClient.Service.Services Log.Debug($"Setting download path for {download.DownloadId} to {downloadPath}"); // Start the download process - var downloadClient = new DownloadClient(download, downloadPath); + var downloadClient = new DownloadClient(download, torrentDownload, downloadPath); if (TorrentRunner.ActiveDownloadClients.TryAdd(download.DownloadId, downloadClient)) { diff --git a/server/RdtClient.Service/Services/Torrents.cs b/server/RdtClient.Service/Services/Torrents.cs index 5abee57..997718b 100644 --- a/server/RdtClient.Service/Services/Torrents.cs +++ b/server/RdtClient.Service/Services/Torrents.cs @@ -440,7 +440,10 @@ namespace RdtClient.Service.Services private async Task Update(Torrent torrent) { - var originalTorrent = JsonConvert.SerializeObject(torrent); + var originalTorrent = JsonConvert.SerializeObject(torrent, new JsonSerializerSettings + { + ReferenceLoopHandling = ReferenceLoopHandling.Ignore + }); var rdTorrent = await GetRdNetClient().GetTorrentInfoAsync(torrent.RdId); @@ -493,7 +496,10 @@ namespace RdtClient.Service.Services _ => RealDebridStatus.Error }; - var newTorrent = JsonConvert.SerializeObject(torrent); + var newTorrent = JsonConvert.SerializeObject(torrent, new JsonSerializerSettings + { + ReferenceLoopHandling = ReferenceLoopHandling.Ignore + }); if (originalTorrent != newTorrent) {