Fixed issue with torrent data caching.

This commit is contained in:
Roger Far 2021-06-05 14:21:29 -06:00
parent f151312d47
commit 71c9eb17fb
5 changed files with 12 additions and 14 deletions

View file

@ -46,14 +46,6 @@ namespace RdtClient.Data.Data
.ToListAsync(); .ToListAsync();
} }
foreach (var torrent in _torrentCache)
{
foreach (var download in torrent.Downloads)
{
download.Torrent = null;
}
}
return _torrentCache.OrderByDescending(m => m.Added).ToList(); return _torrentCache.OrderByDescending(m => m.Added).ToList();
} }
finally finally

View file

@ -21,11 +21,11 @@ namespace RdtClient.Service.Services
private DownloadService _downloader; private DownloadService _downloader;
private SimpleDownloader _simpleDownloader; private SimpleDownloader _simpleDownloader;
public DownloadClient(Download download, String destinationPath) public DownloadClient(Download download, Torrent torrent, String destinationPath)
{ {
_download = download; _download = download;
_torrent = torrent;
_destinationPath = destinationPath; _destinationPath = destinationPath;
_torrent = download.Torrent;
} }
public Boolean Finished { get; private set; } public Boolean Finished { get; private set; }

View file

@ -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); await downloadClient.Start(settings);

View file

@ -253,7 +253,7 @@ namespace RdtClient.Service.Services
Log.Debug($"Setting download path for {download.DownloadId} to {downloadPath}"); Log.Debug($"Setting download path for {download.DownloadId} to {downloadPath}");
// Start the download process // Start the download process
var downloadClient = new DownloadClient(download, downloadPath); var downloadClient = new DownloadClient(download, torrentDownload, downloadPath);
if (TorrentRunner.ActiveDownloadClients.TryAdd(download.DownloadId, downloadClient)) if (TorrentRunner.ActiveDownloadClients.TryAdd(download.DownloadId, downloadClient))
{ {

View file

@ -440,7 +440,10 @@ namespace RdtClient.Service.Services
private async Task Update(Torrent torrent) 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); var rdTorrent = await GetRdNetClient().GetTorrentInfoAsync(torrent.RdId);
@ -493,7 +496,10 @@ namespace RdtClient.Service.Services
_ => RealDebridStatus.Error _ => RealDebridStatus.Error
}; };
var newTorrent = JsonConvert.SerializeObject(torrent); var newTorrent = JsonConvert.SerializeObject(torrent, new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
if (originalTorrent != newTorrent) if (originalTorrent != newTorrent)
{ {