wabbajack/Wabbajack.Server.Lib/DTOs/FtpSite.cs

31 lines
730 B
C#
Raw Normal View History

2021-09-27 12:42:46 +00:00
using System.Net;
using System.Threading.Tasks;
2021-02-06 16:43:11 +00:00
using FluentFTP;
2021-09-27 12:42:46 +00:00
using Microsoft.Extensions.Logging;
using Wabbajack.Common;
2021-10-23 16:51:17 +00:00
namespace Wabbajack.Server.Lib.DTOs;
public enum StorageSpace
2020-05-09 22:16:16 +00:00
{
2021-10-23 16:51:17 +00:00
AuthoredFiles,
Patches,
Mirrors
}
2021-10-23 16:51:17 +00:00
public class FtpSite
{
public string Username { get; set; }
public string Password { get; set; }
public string Hostname { get; set; }
public async Task<FtpClient> GetClient(ILogger logger)
{
return await CircuitBreaker.WithAutoRetryAllAsync(logger, async () =>
{
2021-10-23 16:51:17 +00:00
var ftpClient = new FtpClient(Hostname, new NetworkCredential(Username, Password));
await ftpClient.ConnectAsync();
return ftpClient;
});
2020-05-09 22:16:16 +00:00
}
2021-10-23 16:51:17 +00:00
}