rdt-client/server/RdtClient.Service/Helpers/FileHelper.cs
Roger Far d16e7f0c88 Changed the Aria2 updates to be done in the main TorrentRunner loop instead of each downloader making their own connections.
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.
2021-10-27 14:55:46 -06:00

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);
}
}
}
}
}