Add support for resuming SFTP file upload/download#864
Open
zybexXL wants to merge 7 commits intosshnet:developfrom
Open
Add support for resuming SFTP file upload/download#864zybexXL wants to merge 7 commits intosshnet:developfrom
zybexXL wants to merge 7 commits intosshnet:developfrom
Conversation
zybexXL
commented
Aug 29, 2021
zybexXL
commented
Aug 29, 2021
zybexXL
commented
Aug 29, 2021
zybexXL
commented
Aug 29, 2021
zybexXL
commented
Aug 29, 2021
This was referenced Aug 30, 2021
Closed
Contributor
Author
|
I've rebased this PR, please review and consider merging. |
WojciechNagorski
requested changes
Nov 13, 2023
Collaborator
WojciechNagorski
left a comment
There was a problem hiding this comment.
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
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();
}
Contributor
Author
|
@WojciechNagorski |
Collaborator
|
Sorry for delay. It's correct. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.