Compare commits
No commits in common. "478aaa4daf55004047f6b0d8354dcbde0adcdc96" and "c8d14274720457d669ec7fb389b965eff019f4ee" have entirely different histories.
478aaa4daf
...
c8d1427472
@ -5,8 +5,8 @@
|
|||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AssemblyVersion>1.5.3</AssemblyVersion>
|
<AssemblyVersion>1.5.1</AssemblyVersion>
|
||||||
<FileVersion>1.5.3</FileVersion>
|
<FileVersion>1.5.1</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -25,9 +25,6 @@
|
|||||||
<Reference Include="Gitea">
|
<Reference Include="Gitea">
|
||||||
<HintPath>Resources\Gitea.dll</HintPath>
|
<HintPath>Resources\Gitea.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="WinSCPnet">
|
|
||||||
<HintPath>Resources\WinSCPnet.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -12,7 +12,6 @@ namespace EftPatchHelper.Interfaces
|
|||||||
public string ServiceName { get; set; }
|
public string ServiceName { get; set; }
|
||||||
public string HubEntryText { get; set; }
|
public string HubEntryText { get; set; }
|
||||||
public FileInfo UploadFileInfo { get; }
|
public FileInfo UploadFileInfo { get; }
|
||||||
public bool AddHubEntry { get; }
|
|
||||||
public string GetLink();
|
public string GetLink();
|
||||||
public Task<bool> UploadAsync(IProgress<double>? progress = null);
|
public Task<bool> UploadAsync(IProgress<double>? progress = null);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
using System.Text.Json.Serialization;
|
namespace EftPatchHelper.Model
|
||||||
|
|
||||||
namespace EftPatchHelper.Model
|
|
||||||
{
|
{
|
||||||
public class DownloadMirror
|
public class DownloadMirror
|
||||||
{
|
{
|
||||||
[JsonIgnore]
|
|
||||||
public bool AddHubEntry { get; set; }
|
|
||||||
public string Link { get; set; }
|
public string Link { get; set; }
|
||||||
public string Hash { get; set; }
|
public string Hash { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ namespace EftPatchHelper.Model
|
|||||||
public string DisplayName { get; set; }
|
public string DisplayName { get; set; }
|
||||||
public string ServiceName { get; set; }
|
public string ServiceName { get; set; }
|
||||||
public string HubEntryText { get; set; }
|
public string HubEntryText { get; set; }
|
||||||
public bool AddHubEntry { get; }
|
|
||||||
|
|
||||||
public GoFileUpload(FileInfo file, string apiToken, string folderId)
|
public GoFileUpload(FileInfo file, string apiToken, string folderId)
|
||||||
{
|
{
|
||||||
@ -32,7 +31,6 @@ namespace EftPatchHelper.Model
|
|||||||
ServiceName = "GoFile";
|
ServiceName = "GoFile";
|
||||||
DisplayName = $"{ServiceName} Upload: {UploadFileInfo.Name}";
|
DisplayName = $"{ServiceName} Upload: {UploadFileInfo.Name}";
|
||||||
HubEntryText = $"Download from {ServiceName}";
|
HubEntryText = $"Download from {ServiceName}";
|
||||||
AddHubEntry = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetLink()
|
public string GetLink()
|
||||||
|
@ -17,8 +17,6 @@ namespace EftPatchHelper.Model
|
|||||||
public string DisplayName { get; set; }
|
public string DisplayName { get; set; }
|
||||||
public string ServiceName { get; set; }
|
public string ServiceName { get; set; }
|
||||||
public string HubEntryText { get; set; }
|
public string HubEntryText { get; set; }
|
||||||
public bool AddHubEntry { get; }
|
|
||||||
|
|
||||||
|
|
||||||
public MegaUpload(FileInfo file, string email, string password, string mfaKey = null)
|
public MegaUpload(FileInfo file, string email, string password, string mfaKey = null)
|
||||||
{
|
{
|
||||||
@ -29,7 +27,6 @@ namespace EftPatchHelper.Model
|
|||||||
ServiceName = "Mega";
|
ServiceName = "Mega";
|
||||||
DisplayName = $"{ServiceName} Upload: {UploadFileInfo.Name}";
|
DisplayName = $"{ServiceName} Upload: {UploadFileInfo.Name}";
|
||||||
HubEntryText = $"Download from {ServiceName}";
|
HubEntryText = $"Download from {ServiceName}";
|
||||||
AddHubEntry = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> CheckLoginStatus()
|
private async Task<bool> CheckLoginStatus()
|
||||||
|
@ -39,11 +39,6 @@ namespace EftPatchHelper.Model
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UploadToMega = false;
|
public bool UploadToMega = false;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether or not to upload to all sftp site listing
|
|
||||||
/// </summary>
|
|
||||||
public bool UploadToSftpSites = false;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// List of mirrors to upload to Gitea
|
/// List of mirrors to upload to Gitea
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -57,9 +57,6 @@ namespace EftPatchHelper.Model
|
|||||||
[JsonPropertyName("goFileFolderId")]
|
[JsonPropertyName("goFileFolderId")]
|
||||||
public string GoFileFolderId { get; set; } = "";
|
public string GoFileFolderId { get; set; } = "";
|
||||||
|
|
||||||
[JsonPropertyName("sftpUploads")]
|
|
||||||
public List<SftpUploadInfo> SftpUploads { get; set; } = new();
|
|
||||||
|
|
||||||
public bool Save()
|
public bool Save()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -1,72 +0,0 @@
|
|||||||
using EftPatchHelper.Interfaces;
|
|
||||||
using WinSCP;
|
|
||||||
|
|
||||||
namespace EftPatchHelper.Model;
|
|
||||||
|
|
||||||
public class SftpUpload : IFileUpload
|
|
||||||
{
|
|
||||||
private readonly SftpUploadInfo _sftpInfo;
|
|
||||||
private readonly SessionOptions _sessionOptions;
|
|
||||||
public string DisplayName { get; set; }
|
|
||||||
public string ServiceName { get; set; }
|
|
||||||
public string HubEntryText { get; set; }
|
|
||||||
public bool AddHubEntry { get; }
|
|
||||||
|
|
||||||
public FileInfo UploadFileInfo { get; }
|
|
||||||
|
|
||||||
public SftpUpload(FileInfo file, SftpUploadInfo sftpInfo)
|
|
||||||
{
|
|
||||||
UploadFileInfo = file;
|
|
||||||
_sftpInfo = sftpInfo;
|
|
||||||
|
|
||||||
_sessionOptions = new SessionOptions
|
|
||||||
{
|
|
||||||
Protocol = Protocol.Sftp,
|
|
||||||
UserName = _sftpInfo.Username,
|
|
||||||
Password = _sftpInfo.Password,
|
|
||||||
HostName = _sftpInfo.Hostname,
|
|
||||||
PortNumber = _sftpInfo.Port,
|
|
||||||
SshHostKeyFingerprint = _sftpInfo.HostKey
|
|
||||||
};
|
|
||||||
|
|
||||||
ServiceName = _sftpInfo.Hostname;
|
|
||||||
DisplayName = $"{ServiceName} Upload: {UploadFileInfo.Name}";
|
|
||||||
HubEntryText = $"Download from {ServiceName}";
|
|
||||||
AddHubEntry = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetLink()
|
|
||||||
{
|
|
||||||
return $"{_sftpInfo.HttpPath}/${UploadFileInfo.Name}";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<bool> UploadAsync(IProgress<double>? progress = null)
|
|
||||||
{
|
|
||||||
TransferOptions transferOptions = new TransferOptions
|
|
||||||
{
|
|
||||||
TransferMode = TransferMode.Binary,
|
|
||||||
};
|
|
||||||
|
|
||||||
using Session session = new Session();
|
|
||||||
|
|
||||||
if (progress != null)
|
|
||||||
{
|
|
||||||
session.FileTransferProgress += (_, args) => progress.Report(Math.Floor(args.FileProgress * 100));
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
session.Open(_sessionOptions);
|
|
||||||
|
|
||||||
session.PutFiles(UploadFileInfo.FullName, $"{_sftpInfo.UploadPath}/{UploadFileInfo.Name}", false, transferOptions).Check();
|
|
||||||
|
|
||||||
return Task.FromResult(true);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// ignored
|
|
||||||
}
|
|
||||||
|
|
||||||
return Task.FromResult(false);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
using System.Text.Json.Serialization;
|
|
||||||
|
|
||||||
namespace EftPatchHelper.Model;
|
|
||||||
|
|
||||||
public class SftpUploadInfo
|
|
||||||
{
|
|
||||||
[JsonPropertyName("username")]
|
|
||||||
public string Username { get; set; } = "";
|
|
||||||
|
|
||||||
[JsonPropertyName("password")]
|
|
||||||
public string Password { get; set; } = "";
|
|
||||||
|
|
||||||
[JsonPropertyName("hostKey")]
|
|
||||||
public string HostKey { get; set; } = "";
|
|
||||||
|
|
||||||
[JsonPropertyName("hostname")]
|
|
||||||
public string Hostname { get; set; } = "";
|
|
||||||
|
|
||||||
[JsonPropertyName("port")]
|
|
||||||
public int Port { get; set; } = 0;
|
|
||||||
|
|
||||||
[JsonPropertyName("uploadPath")]
|
|
||||||
public string UploadPath { get; set; } = "";
|
|
||||||
|
|
||||||
[JsonPropertyName("httpPath")]
|
|
||||||
public string HttpPath { get; set; } = "";
|
|
||||||
|
|
||||||
public bool IsValid()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(Username))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(Password))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(Hostname))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(HostKey))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (Port == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(UploadPath))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(HttpPath))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
@ -80,12 +80,6 @@ namespace EftPatchHelper.Tasks
|
|||||||
{
|
{
|
||||||
_options.UploadToGoFile = new ConfirmationPrompt("Upload to GoFile?").Show(AnsiConsole.Console);
|
_options.UploadToGoFile = new ConfirmationPrompt("Upload to GoFile?").Show(AnsiConsole.Console);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_settings.SftpUploads.Count > 0)
|
|
||||||
{
|
|
||||||
_options.UploadToSftpSites =
|
|
||||||
new ConfirmationPrompt($"Upload to SFTP sites? ( {_settings.SftpUploads.Count} sites )").Show(AnsiConsole.Console);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
|
@ -34,18 +34,12 @@ namespace EftPatchHelper.Tasks
|
|||||||
{
|
{
|
||||||
var patcherFile = new FileInfo(_options.OutputPatchPath + ".zip");
|
var patcherFile = new FileInfo(_options.OutputPatchPath + ".zip");
|
||||||
|
|
||||||
if (!patcherFile.Exists)
|
if (!patcherFile.Exists) return false;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
AnsiConsole.WriteLine("Building mirrors list ...");
|
|
||||||
|
|
||||||
if(_settings.UsingGoFile() && _options.UploadToGoFile)
|
if(_settings.UsingGoFile() && _options.UploadToGoFile)
|
||||||
{
|
{
|
||||||
var gofile = new GoFileUpload(patcherFile, _settings.GoFileApiKey, _settings.GoFileFolderId);
|
var gofile = new GoFileUpload(patcherFile, _settings.GoFileApiKey, _settings.GoFileFolderId);
|
||||||
_fileUploads.Add(gofile);
|
_fileUploads.Add(gofile);
|
||||||
AnsiConsole.WriteLine("Added MEGA");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_settings.UsingMega() && _options.UploadToMega)
|
if (_settings.UsingMega() && _options.UploadToMega)
|
||||||
@ -53,21 +47,6 @@ namespace EftPatchHelper.Tasks
|
|||||||
var mega = new MegaUpload(patcherFile, _settings.MegaEmail, _settings.MegaPassword);
|
var mega = new MegaUpload(patcherFile, _settings.MegaEmail, _settings.MegaPassword);
|
||||||
await mega.SetUploadFolder(_settings.MegaUploadFolder);
|
await mega.SetUploadFolder(_settings.MegaUploadFolder);
|
||||||
_fileUploads.Add(mega);
|
_fileUploads.Add(mega);
|
||||||
AnsiConsole.WriteLine("Added MEGA");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_settings.SftpUploads.Count > 0 && _options.UploadToSftpSites)
|
|
||||||
{
|
|
||||||
foreach (var sftpInfo in _settings.SftpUploads)
|
|
||||||
{
|
|
||||||
if (!sftpInfo.IsValid())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
AnsiConsole.WriteLine($"Added SFTP: {sftpInfo.Hostname}");
|
|
||||||
_fileUploads.Add(new SftpUpload(patcherFile, sftpInfo));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -79,11 +58,6 @@ namespace EftPatchHelper.Tasks
|
|||||||
|
|
||||||
foreach (var pair in _options.MirrorList)
|
foreach (var pair in _options.MirrorList)
|
||||||
{
|
{
|
||||||
if (!pair.Value.AddHubEntry)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var displayText = pair.Key;
|
var displayText = pair.Key;
|
||||||
var link = pair.Value.Link;
|
var link = pair.Value.Link;
|
||||||
|
|
||||||
@ -116,12 +90,8 @@ namespace EftPatchHelper.Tasks
|
|||||||
static string BytesToString(long byteCount)
|
static string BytesToString(long byteCount)
|
||||||
{
|
{
|
||||||
string[] suf = { "B", "KB", "MB", "GB", "TB", "PB", "EB" };
|
string[] suf = { "B", "KB", "MB", "GB", "TB", "PB", "EB" };
|
||||||
|
|
||||||
if (byteCount == 0)
|
if (byteCount == 0)
|
||||||
{
|
|
||||||
return "0" + suf[0];
|
return "0" + suf[0];
|
||||||
}
|
|
||||||
|
|
||||||
long bytes = Math.Abs(byteCount);
|
long bytes = Math.Abs(byteCount);
|
||||||
int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)));
|
int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)));
|
||||||
double num = Math.Round(bytes / Math.Pow(1024, place), 1);
|
double num = Math.Round(bytes / Math.Pow(1024, place), 1);
|
||||||
@ -164,9 +134,8 @@ namespace EftPatchHelper.Tasks
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DownloadMirror mirror = new DownloadMirror
|
DownloadMirror mirror = new DownloadMirror()
|
||||||
{
|
{
|
||||||
AddHubEntry = pair.Key.AddHubEntry,
|
|
||||||
Link = pair.Key.GetLink(),
|
Link = pair.Key.GetLink(),
|
||||||
Hash = GetFileHash(pair.Key.UploadFileInfo)
|
Hash = GetFileHash(pair.Key.UploadFileInfo)
|
||||||
};
|
};
|
||||||
@ -183,7 +152,7 @@ namespace EftPatchHelper.Tasks
|
|||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
if (!_options.UploadToGoFile && !_options.UploadToMega && !_options.UploadToSftpSites) return;
|
if (!_options.UploadToGoFile && !_options.UploadToMega) return;
|
||||||
|
|
||||||
UploadAllFiles().GetAwaiter().GetResult().ValidateOrExit();
|
UploadAllFiles().GetAwaiter().GetResult().ValidateOrExit();
|
||||||
|
|
||||||
|
@ -14,18 +14,5 @@
|
|||||||
"megaPassword": "",
|
"megaPassword": "",
|
||||||
"megaUploadFolder": "",
|
"megaUploadFolder": "",
|
||||||
"goFileApiKey": "",
|
"goFileApiKey": "",
|
||||||
"goFileFolderId": "",
|
"goFileFolderId": ""
|
||||||
"sftpUploads": [
|
|
||||||
{
|
|
||||||
"username": "example-remove-before-using",
|
|
||||||
"password": "password123",
|
|
||||||
"hostKey": "ssh-ed12345 SLKDJFK3928D2LDKFJ2",
|
|
||||||
"hostname": "sftp.slugma-ligma.com",
|
|
||||||
"port": 12345,
|
|
||||||
"uploadPath": "/public/patchers",
|
|
||||||
"httpPath": "https://mirror.slugma-ligma.com/patchers"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user