Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: FileTransferProgress called N/sec once e.FileProgress hits 100% on a still growing remote file

Thanks for your report. I'll look into it.
dmitry_20220518

FileTransferProgress called N/sec once e.FileProgress hits 100% on a still growing remote file

Environment:
VS2022 on Windows 10, C#, .NET 4.8, Console App, NuGet downloaded WinSCP assembly on 2022-May-17

  1. On Linux: gzip -c HUGEFILE.txt > growing.gz
  2. On Windows: run Repro.cs
  3. While e.FileProgress is < 100%, callback prints out every second
  4. Once e.FileProgress hits 100%, but with the remote file is still growing, callback is called back constantly

Sample output from below program – look at the milliseconds after it hits 100%

[06:07:41.067] (0%) | [0]
[06:07:41.067] (0%) | [0]
[06:07:41.067] (0%) | [0]
[06:07:42.003] (9%) | [2,424,552]
[06:07:43.012] (26%) | [2,998,804]
[06:07:44.013] (42%) | [3,097,060]
[06:07:45.029] (51%) | [2,797,049]
[06:07:46.006] (68%) | [2,929,040]
[06:07:47.009] (85%) | [3,033,952]
[06:07:47.965] (100%) | [3,059,305]
[06:07:47.965] (100%) | [3,059,305]
[06:07:47.965] (100%) | [3,064,146]
[06:07:47.965] (100%) | [3,064,146]

private class Repro
{
    public void Run()
    {
        SessionOptions sessionOptions = new SessionOptions
        {
            Protocol = Protocol.Sftp,
            HostName = "192.168.1.42",
            UserName = "username",
            Password = "password",
            SshHostKeyFingerprint = "ssh-ed25519 255 fingerprint",
        };
 
        using (Session session = new Session())
        {
            session.FileTransferProgress += Session_FileTransferProgress;
 
            TransferOptions transferOptions = new TransferOptions
            {
                TransferMode = TransferMode.Binary,
                ResumeSupport =
                {
                    State = TransferResumeSupportState.On
                }
            };
 
            session.Open(sessionOptions);
            session.GetFiles($"/tmp/growing.gz", "growing.gz", false, transferOptions).Check();
        }
    }
 
    private void Session_FileTransferProgress(object sender, FileTransferProgressEventArgs e)
    {
        Console.WriteLine($"[{DateTime.Now:hh:mm:ss.fff}] ({e.FileProgress:P0}) | [{e.CPS:N0}]");
    }
}
 
static void Main(string[] args)
{
    Repro r = new Repro();
    r.Run();
}