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

33 lines
821 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-09-27 12:42:46 +00:00
namespace Wabbajack.Server.Lib.DTOs
2020-05-09 22:16:16 +00:00
{
public enum StorageSpace
{
AuthoredFiles,
Patches,
Mirrors
}
2021-09-27 12:42:46 +00:00
public class FtpSite
2020-05-09 22:16:16 +00:00
{
public string Username { get; set; }
public string Password { get; set; }
public string Hostname { get; set; }
2021-09-27 12:42:46 +00:00
public async Task<FtpClient> GetClient(ILogger logger)
{
2021-09-27 12:42:46 +00:00
return await CircuitBreaker.WithAutoRetryAllAsync(logger, async () =>
2021-03-11 04:31:49 +00:00
{
var ftpClient = new FtpClient(Hostname, new NetworkCredential(Username, Password));
await ftpClient.ConnectAsync();
return ftpClient;
});
2021-02-06 16:43:11 +00:00
}
2020-05-09 22:16:16 +00:00
}
}