This commit is contained in:
Roger Far 2026-02-11 20:22:28 -07:00
parent e51e5cde45
commit 580c7132c6
6 changed files with 156 additions and 149 deletions

View file

@ -1,5 +1,4 @@
using RdtClient.Data.Enums; using RdtClient.Data.Enums;
using RdtClient.Data.Models.Data;
using RdtClient.Data.Models.TorrentClient; using RdtClient.Data.Models.TorrentClient;
namespace RdtClient.Data.Models.Internal; namespace RdtClient.Data.Models.Internal;

View file

@ -224,6 +224,7 @@ public class QBittorrent(ILogger<QBittorrent> logger, Settings settings, Authent
var bytesDone = (Int64)(bytesTotal * rdProgress); var bytesDone = (Int64)(bytesTotal * rdProgress);
Double downloadProgress = 0; Double downloadProgress = 0;
if (torrent.Downloads is { Count: > 0 }) if (torrent.Downloads is { Count: > 0 })
{ {
var dlBytesDone = torrent.Downloads.Sum(m => m.BytesDone); var dlBytesDone = torrent.Downloads.Sum(m => m.BytesDone);
@ -235,9 +236,11 @@ public class QBittorrent(ILogger<QBittorrent> logger, Settings settings, Authent
var progress = (rdProgress + downloadProgress) / 2.0; var progress = (rdProgress + downloadProgress) / 2.0;
var remaining = TimeSpan.Zero; var remaining = TimeSpan.Zero;
var bytesRemaining = bytesTotal - bytesDone; var bytesRemaining = bytesTotal - bytesDone;
if (speed > 0 && bytesRemaining > 0) if (speed > 0 && bytesRemaining > 0)
{ {
remaining = TimeSpan.FromSeconds(bytesRemaining / (Double)speed); remaining = TimeSpan.FromSeconds(bytesRemaining / (Double)speed);
// In case there is clock skew // In case there is clock skew
if (remaining < TimeSpan.Zero) if (remaining < TimeSpan.Zero)
{ {

View file

@ -66,8 +66,10 @@ public class RemoteService(IHubContext<RdtHub> hub, Torrents torrents)
BytesTotal = download.BytesTotal, BytesTotal = download.BytesTotal,
BytesDone = download.BytesDone, BytesDone = download.BytesDone,
Speed = download.Speed Speed = download.Speed
}).ToList() })
}).ToList(); .ToList()
})
.ToList();
await hub.Clients.All.SendCoreAsync("update", await hub.Clients.All.SendCoreAsync("update",
[ [

View file

@ -78,8 +78,10 @@ public class TorrentsController(ILogger<TorrentsController> logger, Torrents tor
BytesTotal = download.BytesTotal, BytesTotal = download.BytesTotal,
BytesDone = download.BytesDone, BytesDone = download.BytesDone,
Speed = download.Speed Speed = download.Speed
}).ToList() })
}).ToList(); .ToList()
})
.ToList();
return Ok(torrentDtos); return Ok(torrentDtos);
} }
@ -138,7 +140,7 @@ public class TorrentsController(ILogger<TorrentsController> logger, Torrents tor
RdSpeed = torrent.RdSpeed, RdSpeed = torrent.RdSpeed,
RdSeeders = torrent.RdSeeders, RdSeeders = torrent.RdSeeders,
Files = torrent.Files, Files = torrent.Files,
Downloads = (torrent.Downloads).Select(download => new DownloadDto Downloads = torrent.Downloads.Select(download => new DownloadDto
{ {
DownloadId = download.DownloadId, DownloadId = download.DownloadId,
TorrentId = download.TorrentId, TorrentId = download.TorrentId,
@ -157,7 +159,8 @@ public class TorrentsController(ILogger<TorrentsController> logger, Torrents tor
BytesTotal = download.BytesTotal, BytesTotal = download.BytesTotal,
BytesDone = download.BytesDone, BytesDone = download.BytesDone,
Speed = download.Speed Speed = download.Speed
}).ToList() })
.ToList()
}; };
return Ok(torrentDto); return Ok(torrentDto);