SftpUpload() callback executed out of order
Open
A pull request for this has already been merged.
- #1805 by @Rob-Hague — merged
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 993
- Avg merge
- 9d 21h
- Merged PRs (30d)
- 1
Description
Discussed in https://github.com/sshnet/SSH.NET/discussions/1042
Originally posted by dca00 November 10, 2022
In a simple console app, I pass to SftpClient.SftpUpload() a callback that writes progress to console. Before and after the call I write 'Start' and 'End'. Below is its output:
Start.
X=32739
X=65478
X=98217
X=130956
X=163695
X=229173
X=261912
X=262144
X=196434 <---=== Huh?
End.
Start.
X=32739
X=130956
X=163695
X=196434
X=229173
X=261912
X=262144
End. <---=== Huh?
X=98217 <---=== Huh?
X=65478 <---=== Huh?
Start.
End. <---=== Huh?
X=32739
X=98217
X=130956
X=163695
X=196434
X=229173
X=261912
X=262144
X=65478 <---=== Huh?
Any ideas as to what I am doing wrong?
Console.WriteLine($"Start.");
using (var sftp = new SftpClient("1.1.1.2", "root", "root"))
{
File.WriteAllBytes("test.fil", Enumerable.Repeat<byte>((byte)0, 256 * 1024).ToArray());
using (var stream = File.OpenRead("test.fil"))
{
sftp.Connect();
sftp.ChangeDirectory(".");
sftp.UploadFile(stream, "test.fil", new Action<ulong>(x =>
{
Console.WriteLine($"X={x}");
}));
}
Console.WriteLine($"End.");
}
```</div>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the SftpClient.UploadFile entry point and trace how its progress callback is invoked during the upload. Review the linked merged pull request #1805 for the existing resolution or implementation context. Done means callbacks remain ordered and complete before UploadFile returns and the caller prints End.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100