Fixed retrying failed selecting of torrent files.
This commit is contained in:
parent
34422d7167
commit
4a87a57a65
1 changed files with 22 additions and 3 deletions
|
|
@ -184,16 +184,35 @@ namespace RdtClient.Service.Services
|
||||||
{
|
{
|
||||||
var torrent = await GetById(torrentId);
|
var torrent = await GetById(torrentId);
|
||||||
|
|
||||||
await GetRdNetClient().SelectTorrentFilesAsync(torrent.RdId, fileIds.ToArray());
|
RDNET.Torrent rdTorrent = null;
|
||||||
|
|
||||||
var rdTorrent = await GetRdNetClient().GetTorrentInfoAsync(torrent.RdId);
|
for (var i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
await GetRdNetClient().SelectTorrentFilesAsync(torrent.RdId, fileIds.ToArray());
|
||||||
|
|
||||||
|
await Task.Delay(5000);
|
||||||
|
|
||||||
|
rdTorrent = await GetRdNetClient().GetTorrentInfoAsync(torrent.RdId);
|
||||||
|
|
||||||
|
if (fileIds.Count == rdTorrent.Links.Count)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Task.Delay(10000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rdTorrent == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var file in rdTorrent.Links)
|
foreach (var file in rdTorrent.Links)
|
||||||
{
|
{
|
||||||
// Make sure downloads don't get added multiple times
|
// Make sure downloads don't get added multiple times
|
||||||
var downloadExists = await _downloads.Get(torrent.TorrentId, file);
|
var downloadExists = await _downloads.Get(torrent.TorrentId, file);
|
||||||
|
|
||||||
if (downloadExists == null)
|
if (downloadExists == null && !String.IsNullOrWhiteSpace(file))
|
||||||
{
|
{
|
||||||
await _downloads.Add(torrent.TorrentId, file);
|
await _downloads.Add(torrent.TorrentId, file);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue