Merge pull request #924 from omgbeez/upstream/eta-fix
Update `Logger` to fetch download stats from `TorrentRunner` instead …
This commit is contained in:
commit
bcb24e3bfd
1 changed files with 6 additions and 4 deletions
|
|
@ -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})";
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue