From ed397f82233d9ac80d98176ced6deb48de9f3c05 Mon Sep 17 00:00:00 2001 From: omgbeez <251408589+omgbeez@users.noreply.github.com> Date: Fri, 20 Feb 2026 09:57:57 -0500 Subject: [PATCH] Update `Logger` to use `TorrentRunner.GetStats` for consistent download statistics --- server/RdtClient.Service/Helpers/Logger.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/server/RdtClient.Service/Helpers/Logger.cs b/server/RdtClient.Service/Helpers/Logger.cs index a231577..7244dd4 100644 --- a/server/RdtClient.Service/Helpers/Logger.cs +++ b/server/RdtClient.Service/Helpers/Logger.cs @@ -1,5 +1,6 @@ using System.Web; using RdtClient.Data.Models.Data; +using RdtClient.Service.Services; namespace RdtClient.Service.Helpers; @@ -16,18 +17,19 @@ public static class Logger fileName = HttpUtility.UrlDecode(fileName); } - var done = (Int32)(((Double)download.BytesDone / download.BytesTotal) * 100); + var stats = TorrentRunner.GetStats(download.DownloadId); + var done = (Int32)((Double)stats.BytesDone / stats.BytesTotal * 100); - if (done < 0) + if (done < 0 || Double.IsNaN(done) || Double.IsInfinity(done)) { done = 0; } - return $"for download {fileName}. Completed: {done}%, avg speed: {download.Speed}bytes/s ({download.DownloadId}) remoteID: {download.RemoteId}"; + return $"for download {fileName}. Completed: {done}%, avg speed: {stats.Speed}bytes/s ({download.DownloadId}) remoteID: {download.RemoteId}"; } public static String ToLog(this Torrent torrent) { return $"for torrent {torrent.RdName} ({torrent.RdId} - {torrent.RdStatusRaw} {torrent.RdProgress}%) ({torrent.TorrentId})"; } -} +} \ No newline at end of file