2021-09-27 12:42:46 +00:00
|
|
|
|
using System.Net;
|
2020-08-05 00:34:09 +00:00
|
|
|
|
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;
|
2020-08-05 00:34:09 +00:00
|
|
|
|
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
|
|
|
|
|
}
|
2020-08-05 00:34:09 +00:00
|
|
|
|
|
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 () =>
|
2020-08-05 00:34:09 +00:00
|
|
|
|
{
|
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
|
|
|
|
}
|