diff --git a/EftPatchHelper/EftPatchHelper/EftPatchHelper.csproj b/EftPatchHelper/EftPatchHelper/EftPatchHelper.csproj
index 9b3e04e..b65f54d 100644
--- a/EftPatchHelper/EftPatchHelper/EftPatchHelper.csproj
+++ b/EftPatchHelper/EftPatchHelper/EftPatchHelper.csproj
@@ -5,8 +5,8 @@
net8.0
enable
enable
- 1.5.1
- 1.5.1
+ 1.5.3
+ 1.5.3
diff --git a/EftPatchHelper/EftPatchHelper/Model/Options.cs b/EftPatchHelper/EftPatchHelper/Model/Options.cs
index bc289f3..8f61a80 100644
--- a/EftPatchHelper/EftPatchHelper/Model/Options.cs
+++ b/EftPatchHelper/EftPatchHelper/Model/Options.cs
@@ -39,6 +39,11 @@ namespace EftPatchHelper.Model
///
public bool UploadToMega = false;
+ ///
+ /// Whether or not to upload to all sftp site listing
+ ///
+ public bool UploadToSftpSites = false;
+
///
/// List of mirrors to upload to Gitea
///
diff --git a/EftPatchHelper/EftPatchHelper/Model/Settings.cs b/EftPatchHelper/EftPatchHelper/Model/Settings.cs
index a157fd7..0c24b4c 100644
--- a/EftPatchHelper/EftPatchHelper/Model/Settings.cs
+++ b/EftPatchHelper/EftPatchHelper/Model/Settings.cs
@@ -57,7 +57,7 @@ namespace EftPatchHelper.Model
[JsonPropertyName("goFileFolderId")]
public string GoFileFolderId { get; set; } = "";
- [JsonPropertyName("sftpUploads")]
+ [JsonPropertyName("sftpUploads")]
public List SftpUploads { get; set; } = new();
public bool Save()
diff --git a/EftPatchHelper/EftPatchHelper/Model/SftpUpload.cs b/EftPatchHelper/EftPatchHelper/Model/SftpUpload.cs
index ca59a91..e412ab8 100644
--- a/EftPatchHelper/EftPatchHelper/Model/SftpUpload.cs
+++ b/EftPatchHelper/EftPatchHelper/Model/SftpUpload.cs
@@ -22,6 +22,8 @@ public class SftpUpload : IFileUpload
_sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
+ UserName = _sftpInfo.Username,
+ Password = _sftpInfo.Password,
HostName = _sftpInfo.Hostname,
PortNumber = _sftpInfo.Port,
SshHostKeyFingerprint = _sftpInfo.HostKey
@@ -40,25 +42,23 @@ public class SftpUpload : IFileUpload
public Task UploadAsync(IProgress? progress = null)
{
- TransferOptions transferOptions = new TransferOptions()
+ TransferOptions transferOptions = new TransferOptions
{
TransferMode = TransferMode.Binary,
};
using Session session = new Session();
- using var uploadStream = UploadFileInfo.OpenRead();
if (progress != null)
{
- session.FileTransferProgress += (_, args) => progress.Report(args.FileProgress);
+ session.FileTransferProgress += (_, args) => progress.Report(Math.Floor(args.FileProgress * 100));
}
try
{
-
session.Open(_sessionOptions);
- session.PutFile(uploadStream, _sftpInfo.UploadPath, transferOptions);
+ session.PutFiles(UploadFileInfo.FullName, $"{_sftpInfo.UploadPath}/{UploadFileInfo.Name}", false, transferOptions).Check();
return Task.FromResult(true);
}
diff --git a/EftPatchHelper/EftPatchHelper/Model/SftpUploadInfo.cs b/EftPatchHelper/EftPatchHelper/Model/SftpUploadInfo.cs
index 8b1d38f..b9d8f9c 100644
--- a/EftPatchHelper/EftPatchHelper/Model/SftpUploadInfo.cs
+++ b/EftPatchHelper/EftPatchHelper/Model/SftpUploadInfo.cs
@@ -25,24 +25,27 @@ public class SftpUploadInfo
[JsonPropertyName("httpPath")]
public string HttpPath { get; set; } = "";
- public bool Validate()
+ public bool IsValid()
{
- if (!string.IsNullOrWhiteSpace(Username))
+ if (string.IsNullOrWhiteSpace(Username))
return false;
- if (!string.IsNullOrWhiteSpace(Password))
+ if (string.IsNullOrWhiteSpace(Password))
+ return false;
+
+ if (string.IsNullOrWhiteSpace(Hostname))
return false;
- if (!string.IsNullOrWhiteSpace(HostKey))
+ if (string.IsNullOrWhiteSpace(HostKey))
return false;
if (Port == 0)
return false;
- if (!string.IsNullOrWhiteSpace(UploadPath))
+ if (string.IsNullOrWhiteSpace(UploadPath))
return false;
- if (!string.IsNullOrWhiteSpace(HttpPath))
+ if (string.IsNullOrWhiteSpace(HttpPath))
return false;
return true;
diff --git a/EftPatchHelper/EftPatchHelper/Resources/WinSCPnet.dll b/EftPatchHelper/EftPatchHelper/Resources/WinSCPnet.dll
index 0d01b09..fe34dc9 100644
Binary files a/EftPatchHelper/EftPatchHelper/Resources/WinSCPnet.dll and b/EftPatchHelper/EftPatchHelper/Resources/WinSCPnet.dll differ
diff --git a/EftPatchHelper/EftPatchHelper/Tasks/StartupSettingsTask.cs b/EftPatchHelper/EftPatchHelper/Tasks/StartupSettingsTask.cs
index ba47508..d863c11 100644
--- a/EftPatchHelper/EftPatchHelper/Tasks/StartupSettingsTask.cs
+++ b/EftPatchHelper/EftPatchHelper/Tasks/StartupSettingsTask.cs
@@ -80,6 +80,12 @@ namespace EftPatchHelper.Tasks
{
_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()
diff --git a/EftPatchHelper/EftPatchHelper/Tasks/UploadTasks.cs b/EftPatchHelper/EftPatchHelper/Tasks/UploadTasks.cs
index 324ae86..1685a76 100644
--- a/EftPatchHelper/EftPatchHelper/Tasks/UploadTasks.cs
+++ b/EftPatchHelper/EftPatchHelper/Tasks/UploadTasks.cs
@@ -38,11 +38,14 @@ namespace EftPatchHelper.Tasks
{
return false;
}
+
+ AnsiConsole.WriteLine("Building mirrors list ...");
if(_settings.UsingGoFile() && _options.UploadToGoFile)
{
var gofile = new GoFileUpload(patcherFile, _settings.GoFileApiKey, _settings.GoFileFolderId);
_fileUploads.Add(gofile);
+ AnsiConsole.WriteLine("Added MEGA");
}
if (_settings.UsingMega() && _options.UploadToMega)
@@ -50,16 +53,21 @@ namespace EftPatchHelper.Tasks
var mega = new MegaUpload(patcherFile, _settings.MegaEmail, _settings.MegaPassword);
await mega.SetUploadFolder(_settings.MegaUploadFolder);
_fileUploads.Add(mega);
+ AnsiConsole.WriteLine("Added MEGA");
}
- foreach (var sftpInfo in _settings.SftpUploads)
+ if (_settings.SftpUploads.Count > 0 && _options.UploadToSftpSites)
{
- if (!sftpInfo.Validate())
+ foreach (var sftpInfo in _settings.SftpUploads)
{
- continue;
+ if (!sftpInfo.IsValid())
+ {
+ continue;
+ }
+
+ AnsiConsole.WriteLine($"Added SFTP: {sftpInfo.Hostname}");
+ _fileUploads.Add(new SftpUpload(patcherFile, sftpInfo));
}
-
- _fileUploads.Add(new SftpUpload(patcherFile, sftpInfo));
}
return true;
@@ -76,7 +84,6 @@ namespace EftPatchHelper.Tasks
continue;
}
-
var displayText = pair.Key;
var link = pair.Value.Link;
@@ -176,7 +183,7 @@ namespace EftPatchHelper.Tasks
public void Run()
{
- if (!_options.UploadToGoFile && !_options.UploadToMega) return;
+ if (!_options.UploadToGoFile && !_options.UploadToMega && !_options.UploadToSftpSites) return;
UploadAllFiles().GetAwaiter().GetResult().ValidateOrExit();