Added checks if Aria2 links actually got added. Improved debug messages and set Microsoft message to Warning. Abstracted the RealDebrid client into a ITorrentClient. Add retry mechanism for server errors from RealDebrid.
45 lines
872 B
C#
45 lines
872 B
C#
using System;
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace RdtClient.Service.Helpers
|
|
{
|
|
public static class FileHelper
|
|
{
|
|
public static async Task Delete(String path)
|
|
{
|
|
if (String.IsNullOrWhiteSpace(path))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!File.Exists(path))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var retry = 0;
|
|
|
|
while (true)
|
|
{
|
|
try
|
|
{
|
|
File.Delete(path);
|
|
|
|
break;
|
|
}
|
|
catch
|
|
{
|
|
if (retry >= 3)
|
|
{
|
|
throw;
|
|
}
|
|
|
|
retry++;
|
|
|
|
await Task.Delay(1000 * retry);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|