Skip to content

Commit

Permalink
fresh sftp connection for dispose
Browse files Browse the repository at this point in the history
  • Loading branch information
JFriel committed Aug 7, 2024
1 parent 90591b9 commit 2fb1baa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Rdmp.Core/DataLoad/Modules/FTP/SFTPDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class SFTPDownloader : FTPDownloader
[DemandsInitialization("The keep-alive interval. In milliseconds. Requires KeepAlive to be set to take effect.")]
public int KeepAliveIntervalMilliseconds { get; set; }

private readonly Lazy<SftpClient> _connection;
private Lazy<SftpClient> _connection;

public SFTPDownloader(Lazy<SftpClient> connection)
{
Expand Down Expand Up @@ -87,11 +87,12 @@ protected override void Download(string file, ILoadDirectory destination)

public override void LoadCompletedSoDispose(ExitCodeType exitCode, IDataLoadEventListener postLoadEventListener)
{
if (exitCode != ExitCodeType.Success) return;
if (exitCode != ExitCodeType.Success || !DeleteFilesOffFTPServerAfterSuccesfulDataLoad) return;

// Reconnect if we got cut off, for example due to idle timers
if (!_connection.Value.IsConnected)
_connection.Value.Connect();
//if (!_connection.Value.IsConnected)
// _connection.Value.Connect();
_connection = new Lazy<SftpClient>(SetupSftp, LazyThreadSafetyMode.ExecutionAndPublication);

foreach (var retrievedFiles in _filesRetrieved)
try
Expand Down
1 change: 1 addition & 0 deletions Rdmp.Core/DataLoad/Modules/Mutilators/DQEPostLoadRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Rdmp.Core.ReusableLibraryCode.Progress;
using System;
using System.Linq;
using System.Threading;

namespace Rdmp.Core.DataLoad.Modules.Mutilators;

Expand Down

0 comments on commit 2fb1baa

Please sign in to comment.