Skip to content

Commit 803cdcc

Browse files
committed
fix: Potentially catch SSH downloads that don't happen due to bad config.
1 parent f283030 commit 803cdcc

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

RemoteFile/RemoteHandlers/SSHHandler.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,14 @@ public override byte[] DownloadCertificateFile(string path)
260260

261261
bool scpError = false;
262262

263+
_logger.LogDebug($"Download path: {downloadPath}");
264+
_logger.LogDebug($"IsStoreServerLinux: {IsStoreServerLinux}");
265+
_logger.LogDebug($"FileTransferProtocol: {FileTransferProtocol}");
266+
bool attemptedDownload = false;
267+
263268
if (FileTransferProtocol == ApplicationSettings.FileTransferProtocolEnum.Both || FileTransferProtocol == ApplicationSettings.FileTransferProtocolEnum.SCP)
264269
{
270+
_logger.LogDebug($"Attempting SCP download...");
265271
using (ScpClient client = new ScpClient(Connection))
266272
{
267273
try
@@ -288,13 +294,15 @@ public override byte[] DownloadCertificateFile(string path)
288294
}
289295
finally
290296
{
297+
attemptedDownload = true;
291298
client.Disconnect();
292299
}
293300
}
294301
}
295302

296303
if ((FileTransferProtocol == ApplicationSettings.FileTransferProtocolEnum.Both && scpError) || FileTransferProtocol == ApplicationSettings.FileTransferProtocolEnum.SFTP)
297304
{
305+
_logger.LogDebug($"Attempting SFTP download...");
298306
using (SftpClient client = new SftpClient(Connection))
299307
{
300308
try
@@ -317,10 +325,17 @@ public override byte[] DownloadCertificateFile(string path)
317325
}
318326
finally
319327
{
328+
attemptedDownload = true;
320329
client.Disconnect();
321330
}
322331
}
323332
}
333+
if (!attemptedDownload)
334+
{
335+
FileTransferProtocol = ApplicationSettings.FileTransferProtocolEnum.Both;
336+
_logger.LogDebug($"No download attempted. Setting FileTransferProtocol to Both and retrying download.");
337+
return DownloadCertificateFile(path);
338+
}
324339

325340
if (!string.IsNullOrEmpty(ApplicationSettings.SeparateUploadFilePath) && IsStoreServerLinux)
326341
{

0 commit comments

Comments
 (0)