Skip to content

Commit

Permalink
improve #660
Browse files Browse the repository at this point in the history
  • Loading branch information
VShawn committed May 9, 2024
1 parent 9de29a7 commit 1b9f5aa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
33 changes: 18 additions & 15 deletions Ui/Model/Protocol/FileTransmit/Transmitters/TransmitterSFtp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,24 +300,27 @@ private void InitClient()
{
if (_sftp?.IsConnected != true)
{
_sftp?.Dispose();
if (string.IsNullOrEmpty(Password)
&& string.IsNullOrEmpty(SshKeyPath) == false
&& File.Exists(SshKeyPath))
RetryHelper.Try(() =>
{
try
_sftp?.Dispose();
if (string.IsNullOrEmpty(Password)
&& string.IsNullOrEmpty(SshKeyPath) == false
&& File.Exists(SshKeyPath))
{
var connectionInfo = new ConnectionInfo(Hostname, Port, Username, new PrivateKeyAuthenticationMethod(Username, new PrivateKeyFile(SshKeyPath)));
_sftp = new SftpClient(connectionInfo);
try
{
var connectionInfo = new ConnectionInfo(Hostname, Port, Username, new PrivateKeyAuthenticationMethod(Username, new PrivateKeyFile(SshKeyPath)));
_sftp = new SftpClient(connectionInfo);
}
catch (Exception e)
{
MsAppCenterHelper.Error(e);
}
}
catch (Exception e)
{
MsAppCenterHelper.Error(e);
}
}
_sftp ??= new SftpClient(new ConnectionInfo(Hostname, Port, Username, new PasswordAuthenticationMethod(Username, Password)));
//_sftp.KeepAliveInterval = new TimeSpan(0, 0, 10);
_sftp.Connect();
_sftp ??= new SftpClient(new ConnectionInfo(Hostname, Port, Username, new PasswordAuthenticationMethod(Username, Password)));
//_sftp.KeepAliveInterval = new TimeSpan(0, 0, 10);
_sftp.Connect();
});
}
}
}
Expand Down

0 comments on commit 1b9f5aa

Please sign in to comment.