- Fix incorrect download speed calculation
- Add debug logging to the download section
This commit is contained in:
Stone_Red
2022-03-02 19:05:45 +01:00
parent a90af811c1
commit 6572e5bda5
@@ -169,8 +169,9 @@ public class DownloadCommands
{ {
bytesRead = nwStream.Read(reciveBuffer, 0, reciveBuffer.Length); bytesRead = nwStream.Read(reciveBuffer, 0, reciveBuffer.Length);
} }
catch (IOException) catch (IOException ex)
{ {
Debug.WriteLine(ex);
ApiManager.SendMessageNewLine(string.Empty); ApiManager.SendMessageNewLine(string.Empty);
ApiManager.SendMessageNewLine("Lost connection to other host!", NotificationMessageType.Error); ApiManager.SendMessageNewLine("Lost connection to other host!", NotificationMessageType.Error);
break; break;
@@ -183,9 +184,9 @@ public class DownloadCommands
bytesInOneSecond += bytesRead; bytesInOneSecond += bytesRead;
if (stopWatch.ElapsedMilliseconds >= 1000) if (stopWatch.Elapsed.TotalSeconds >= 1)
{ {
unitsPerSecond = (unitsPerSecond + bytesInOneSecond) / 2; unitsPerSecond = (int)(bytesInOneSecond * stopWatch.Elapsed.TotalSeconds);
if (unitsPerSecond > 125000) if (unitsPerSecond > 125000)
{ {
unitsPerSecond /= 125000; unitsPerSecond /= 125000;