Merge pull request #924 from omgbeez/upstream/eta-fix

Update `Logger` to fetch download stats from `TorrentRunner` instead …
This commit is contained in:
Roger Far 2026-02-21 15:14:34 -07:00 committed by GitHub
commit bcb24e3bfd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,6 @@
using System.Web; using System.Web;
using RdtClient.Data.Models.Data; using RdtClient.Data.Models.Data;
using RdtClient.Service.Services;
namespace RdtClient.Service.Helpers; namespace RdtClient.Service.Helpers;
@ -16,18 +17,19 @@ public static class Logger
fileName = HttpUtility.UrlDecode(fileName); 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; 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) public static String ToLog(this Torrent torrent)
{ {
return $"for torrent {torrent.RdName} ({torrent.RdId} - {torrent.RdStatusRaw} {torrent.RdProgress}%) ({torrent.TorrentId})"; return $"for torrent {torrent.RdName} ({torrent.RdId} - {torrent.RdStatusRaw} {torrent.RdProgress}%) ({torrent.TorrentId})";
} }
} }