2
0
mirror of synced 2025-01-12 09:34:40 +00:00

div by zero in time calculation

This commit is contained in:
benbierens 2024-09-12 15:14:15 +02:00
parent 88c675adf9
commit 769b9c3aca
No known key found for this signature in database
GPG Key ID: 877D2C2E09A22F3A

View File

@ -18,8 +18,9 @@ namespace AutoClient
public void DownloadSuccessful(long size, TimeSpan time)
{
long seconds = Convert.ToInt64(time.TotalSeconds);
long bytesPerSecond = size / seconds;
long milliseconds = Convert.ToInt64(time.TotalMilliseconds);
if (milliseconds < 1) milliseconds = 1;
long bytesPerSecond = 1000 * (size / milliseconds);
Log($"Download successful: {bytesPerSecond} bytes per second");
}
@ -50,8 +51,9 @@ namespace AutoClient
public void UploadSuccessful(long size, TimeSpan time)
{
long seconds = Convert.ToInt64(time.TotalSeconds);
long bytesPerSecond = size / seconds;
long milliseconds = Convert.ToInt64(time.TotalMilliseconds);
if (milliseconds < 1) milliseconds = 1;
long bytesPerSecond = 1000 * (size / milliseconds);
Log($"Upload successful: {bytesPerSecond} bytes per second");
}