Finished torrent retry.
This commit is contained in:
parent
399456c815
commit
ae41865bb2
5 changed files with 50 additions and 36 deletions
|
|
@ -15,4 +15,5 @@ export class Download {
|
|||
public bytesTotal: number;
|
||||
public bytesDone: number;
|
||||
public speed: number;
|
||||
public retryCount: number;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ export class Torrent {
|
|||
public fileOrMagnet: string;
|
||||
public isFile: boolean;
|
||||
|
||||
public retryCount: number;
|
||||
|
||||
public rdId: string;
|
||||
public rdName: string;
|
||||
public rdSize: number;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@
|
|||
<label class="label">Status</label>
|
||||
{{ torrent | status }}
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Retry count</label>
|
||||
{{ torrent.retryCount }} / 2
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Hash</label>
|
||||
{{ torrent.hash }}
|
||||
|
|
@ -245,7 +249,7 @@
|
|||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Retry Count</label>
|
||||
{{ download.retryCount }}
|
||||
{{ download.retryCount }} / 3
|
||||
</div>
|
||||
</div>
|
||||
<div fxFlex>
|
||||
|
|
|
|||
|
|
@ -115,7 +115,10 @@ namespace RdtClient.Service.Services
|
|||
{
|
||||
Log.Debug($"Processing active download {downloadId}: error {downloadClient.Error}, download retry count {download.RetryCount}/{DownloadRetryCount}, torrent retry count {download.Torrent.RetryCount}/{TorrentRetryCount}, retrying torrent");
|
||||
|
||||
await _torrents.RetryTorrent(download.TorrentId);
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await _torrents.RetryTorrent(download.TorrentId);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -101,12 +101,12 @@ namespace RdtClient.Service.Services
|
|||
await _torrentData.UpdateCategory(torrent.TorrentId, category);
|
||||
}
|
||||
|
||||
public async Task UploadMagnet(String magnetLink,
|
||||
String category,
|
||||
TorrentDownloadAction downloadAction,
|
||||
TorrentFinishedAction finishedAction,
|
||||
Int32 downloadMinSize,
|
||||
String downloadManualFiles)
|
||||
public async Task<Torrent> UploadMagnet(String magnetLink,
|
||||
String category,
|
||||
TorrentDownloadAction downloadAction,
|
||||
TorrentFinishedAction finishedAction,
|
||||
Int32 downloadMinSize,
|
||||
String downloadManualFiles)
|
||||
{
|
||||
MagnetLink magnet;
|
||||
|
||||
|
|
@ -121,15 +121,15 @@ namespace RdtClient.Service.Services
|
|||
|
||||
var rdTorrent = await GetRdNetClient().Torrents.AddMagnetAsync(magnetLink);
|
||||
|
||||
await Add(rdTorrent.Id, magnet.InfoHash.ToHex(), category, downloadAction, finishedAction, downloadMinSize, downloadManualFiles, magnetLink, false);
|
||||
return await Add(rdTorrent.Id, magnet.InfoHash.ToHex(), category, downloadAction, finishedAction, downloadMinSize, downloadManualFiles, magnetLink, false);
|
||||
}
|
||||
|
||||
public async Task UploadFile(Byte[] bytes,
|
||||
String category,
|
||||
TorrentDownloadAction downloadAction,
|
||||
TorrentFinishedAction finishedAction,
|
||||
Int32 downloadMinSize,
|
||||
String downloadManualFiles)
|
||||
public async Task<Torrent> UploadFile(Byte[] bytes,
|
||||
String category,
|
||||
TorrentDownloadAction downloadAction,
|
||||
TorrentFinishedAction finishedAction,
|
||||
Int32 downloadMinSize,
|
||||
String downloadManualFiles)
|
||||
{
|
||||
MonoTorrent.Torrent torrent;
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ namespace RdtClient.Service.Services
|
|||
|
||||
var rdTorrent = await GetRdNetClient().Torrents.AddFileAsync(bytes);
|
||||
|
||||
await Add(rdTorrent.Id, torrent.InfoHash.ToHex(), category, downloadAction, finishedAction, downloadMinSize, downloadManualFiles, fileAsBase64, true);
|
||||
return await Add(rdTorrent.Id, torrent.InfoHash.ToHex(), category, downloadAction, finishedAction, downloadMinSize, downloadManualFiles, fileAsBase64, true);
|
||||
}
|
||||
|
||||
public async Task<List<TorrentInstantAvailabilityFile>> GetAvailableFiles(String hash)
|
||||
|
|
@ -394,14 +394,14 @@ namespace RdtClient.Service.Services
|
|||
{
|
||||
downloadClient.Cancel();
|
||||
|
||||
await Task.Delay(1000);
|
||||
await Task.Delay(100);
|
||||
}
|
||||
|
||||
while (TorrentRunner.ActiveUnpackClients.TryGetValue(download.DownloadId, out var unpackClient))
|
||||
{
|
||||
unpackClient.Cancel();
|
||||
|
||||
await Task.Delay(1000);
|
||||
await Task.Delay(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -416,23 +416,25 @@ namespace RdtClient.Service.Services
|
|||
|
||||
try
|
||||
{
|
||||
Torrent newTorrent;
|
||||
|
||||
if (torrent.IsFile)
|
||||
{
|
||||
var bytes = Convert.FromBase64String(torrent.FileOrMagnet);
|
||||
|
||||
await UploadFile(bytes, torrent.Category, torrent.DownloadAction, torrent.FinishedAction, torrent.DownloadMinSize, torrent.DownloadManualFiles);
|
||||
newTorrent = await UploadFile(bytes, torrent.Category, torrent.DownloadAction, torrent.FinishedAction, torrent.DownloadMinSize, torrent.DownloadManualFiles);
|
||||
}
|
||||
else
|
||||
{
|
||||
await UploadMagnet(torrent.FileOrMagnet,
|
||||
torrent.Category,
|
||||
torrent.DownloadAction,
|
||||
torrent.FinishedAction,
|
||||
torrent.DownloadMinSize,
|
||||
torrent.DownloadManualFiles);
|
||||
newTorrent = await UploadMagnet(torrent.FileOrMagnet,
|
||||
torrent.Category,
|
||||
torrent.DownloadAction,
|
||||
torrent.FinishedAction,
|
||||
torrent.DownloadMinSize,
|
||||
torrent.DownloadManualFiles);
|
||||
}
|
||||
|
||||
await _torrentData.UpdateRetryCount(torrent.TorrentId, newRetryCount);
|
||||
await _torrentData.UpdateRetryCount(newTorrent.TorrentId, newRetryCount);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
@ -530,15 +532,15 @@ namespace RdtClient.Service.Services
|
|||
return settingDownloadPath;
|
||||
}
|
||||
|
||||
private async Task Add(String rdTorrentId,
|
||||
String infoHash,
|
||||
String category,
|
||||
TorrentDownloadAction downloadAction,
|
||||
TorrentFinishedAction finishedAction,
|
||||
Int32 downloadMinSize,
|
||||
String downloadManualFiles,
|
||||
String fileOrMagnetContents,
|
||||
Boolean isFile)
|
||||
private async Task<Torrent> Add(String rdTorrentId,
|
||||
String infoHash,
|
||||
String category,
|
||||
TorrentDownloadAction downloadAction,
|
||||
TorrentFinishedAction finishedAction,
|
||||
Int32 downloadMinSize,
|
||||
String downloadManualFiles,
|
||||
String fileOrMagnetContents,
|
||||
Boolean isFile)
|
||||
{
|
||||
await RealDebridUpdateLock.WaitAsync();
|
||||
|
||||
|
|
@ -548,7 +550,7 @@ namespace RdtClient.Service.Services
|
|||
|
||||
if (torrent != null)
|
||||
{
|
||||
return;
|
||||
return torrent;
|
||||
}
|
||||
|
||||
var newTorrent = await _torrentData.Add(rdTorrentId,
|
||||
|
|
@ -562,6 +564,8 @@ namespace RdtClient.Service.Services
|
|||
isFile);
|
||||
|
||||
await Update(newTorrent);
|
||||
|
||||
return newTorrent;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue