Incorrect Bytes Per Second Calculation

Jun 10, 2011 at 11:52 PM

I've been using the FtpClient library for a couple of weeks now and have found it useful. Thanks for your work.

 

I have come across one bug in the FTPTransferInfo class whereby a resumed transfer will result in the incorrect calculation of bytes per second. I believe the accessor method should be as follows. This calculation takes into account the rest value and as such reports the bytes per second correctly even when resuming a transfer.

 

public long BytesPerSecond
{
    get
    {
        TimeSpan t = this.Now.Subtract(this.Start);

        if (Transferred > 0 && t.TotalSeconds > 0)
        {
            return (long)Math.Round( (Transferred-Rest) / t.TotalSeconds, 0);
        }

        return 0;
    }
}

Coordinator
Jun 13, 2011 at 8:34 PM

Thanks for pointing this out, should be fixed in the latest revision.