SSH.NET icon indicating copy to clipboard operation
SSH.NET copied to clipboard

Add support for resuming SFTP file upload/download

Open zybexXL opened this issue 4 years ago • 3 comments

This adds resume capability to SftpClient.UploadFile() , SftpClient.DownloadFile(), as well as to the BeginUploadFile() and BeginDownloadFile() 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:

  • Setting a non-zero position on the input Stream for UploadFile() triggers an Append to the remote file. It's up to the caller to first check the current size of the remote file and set the local position accordingly!
  • Setting a non-zero position on the output Stream for DownloadFile() triggers a resume of the download at the given position.

This also does NOT check if the server supports Resume, though all servers I've tested so far do support it.

zybexXL avatar Aug 27 '21 15:08 zybexXL

I've rebased this PR, please review and consider merging.

zybexXL avatar Nov 01 '23 19:11 zybexXL

@WojciechNagorski This type of Resume test won't work as the test file may well finish upload/download before the Disruptor kicks in, especially if the test server is in localhost. Better to upload a small file, then reconnect and append some more data, then check if the filesize is as expected. The download resume test can download the file in 2 chunks and check if it's correct. OK ?

zybexXL avatar Nov 20 '23 21:11 zybexXL

Sorry for delay. It's correct.

WojciechNagorski avatar Dec 20 '23 11:12 WojciechNagorski