Update Logger to use TorrentRunner.GetStats for consistent download statistics

This commit is contained in:
omgbeez 2026-02-20 09:57:57 -05:00 committed by Clifford Roche
parent 6572ba752c
commit ed397f8223

View file

@ -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})";
}
}
}