-
-
Notifications
You must be signed in to change notification settings - Fork 934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for resuming SFTP file upload/download #864
base: develop
Are you sure you want to change the base?
Conversation
I've rebased this PR, please review and consider merging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked this PR and it looks great!
I just want you to provide two integration tests for upload and download.
You can use similar mechanism, like in
public void Common_LossOfNetworkConnectivityDisconnectAndConnect() |
bool vmNetworkConnectionDisabled = false;
SshConnectionRestorer disruptor = null;
try
{
using (var client = new SftpClient(_connectionInfoFactory.Create()))
{
client.Connect();
// <-- Start upload/download file
disruptor = _sshConnectionDisruptor.BreakConnections();
vmNetworkConnectionDisabled = true;
WaitForConnectionInterruption(client);
// disconnect while network connectivity is lost
client.Disconnect();
Assert.IsFalse(client.IsConnected);
disruptor.RestoreConnections();
vmNetworkConnectionDisabled = false;
// connect when network connectivity is restored
client.Connect();
// <-- Resume download/upload file
client.Dispose();
}
}
finally
{
if (vmNetworkConnectionDisabled)
{
disruptor.RestoreConnections();
}
disruptor?.Dispose();
}
@WojciechNagorski |
Sorry for delay. It's correct. |
This adds resume capability to
SftpClient.UploadFile()
,SftpClient.DownloadFile()
, as well as to theBeginUploadFile()
andBeginDownloadFile()
variants.The API remains unchanged. Resume is triggered simply by changing the current Position of the input/output stream which is given as an argument to these functions:
This also does NOT check if the server supports Resume, though all servers I've tested so far do support it.