From 6572e5bda5d61a6c92880d85d47d06fead3c1783 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Wed, 2 Mar 2022 19:05:45 +0100 Subject: [PATCH] Fix bug - Fix incorrect download speed calculation - Add debug logging to the download section --- HyperbolicDownloaderApi/Commands/DownloadCommands.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/HyperbolicDownloaderApi/Commands/DownloadCommands.cs b/HyperbolicDownloaderApi/Commands/DownloadCommands.cs index ef28120..7b51d8f 100644 --- a/HyperbolicDownloaderApi/Commands/DownloadCommands.cs +++ b/HyperbolicDownloaderApi/Commands/DownloadCommands.cs @@ -169,8 +169,9 @@ public class DownloadCommands { bytesRead = nwStream.Read(reciveBuffer, 0, reciveBuffer.Length); } - catch (IOException) + catch (IOException ex) { + Debug.WriteLine(ex); ApiManager.SendMessageNewLine(string.Empty); ApiManager.SendMessageNewLine("Lost connection to other host!", NotificationMessageType.Error); break; @@ -183,9 +184,9 @@ public class DownloadCommands bytesInOneSecond += bytesRead; - if (stopWatch.ElapsedMilliseconds >= 1000) + if (stopWatch.Elapsed.TotalSeconds >= 1) { - unitsPerSecond = (unitsPerSecond + bytesInOneSecond) / 2; + unitsPerSecond = (int)(bytesInOneSecond * stopWatch.Elapsed.TotalSeconds); if (unitsPerSecond > 125000) { unitsPerSecond /= 125000;