diff --git a/server/RdtClient.Service/Services/DownloadClient.cs b/server/RdtClient.Service/Services/DownloadClient.cs index ecc3ba3..d3e9c63 100644 --- a/server/RdtClient.Service/Services/DownloadClient.cs +++ b/server/RdtClient.Service/Services/DownloadClient.cs @@ -33,8 +33,8 @@ namespace RdtClient.Service.Services public Int64 BytesTotal { get; private set; } public Int64 BytesDone { get; private set; } - private static Int64 LastTick { get; set; } - private static ConcurrentBag AverageSpeed { get; } = new ConcurrentBag(); + private Int64 LastTick { get; set; } + private ConcurrentBag AverageSpeed { get; } = new ConcurrentBag(); public async Task Start(Boolean onTheFlyDownload, String tempDirectory, Int32 chunkCount, Int64 maximumBytesPerSecond) { @@ -123,7 +123,11 @@ namespace RdtClient.Service.Services LastTick = Environment.TickCount; } - Speed = (Int64) AverageSpeed.Average(); + if (AverageSpeed.Count > 0) + { + Speed = (Int64) AverageSpeed.Average(); + } + BytesDone = args.ReceivedBytesSize; BytesTotal = args.TotalBytesToReceive; }; diff --git a/server/RdtClient.Service/Services/TorrentRunner.cs b/server/RdtClient.Service/Services/TorrentRunner.cs index 6ee9c14..37b7d09 100644 --- a/server/RdtClient.Service/Services/TorrentRunner.cs +++ b/server/RdtClient.Service/Services/TorrentRunner.cs @@ -161,14 +161,14 @@ namespace RdtClient.Service.Services var torrents = await _torrents.Get(); - // Only poll RealDebrid every 5 when a hub is connected, otherwise ever 30 seconds + // Only poll RealDebrid every second when a hub is connected, otherwise every 30 seconds if (_nextUpdate < DateTime.UtcNow && torrents.Count > 0) { var updateTime = 30; if (RdtHub.HasConnections) { - updateTime = 5; + updateTime = 1; } _nextUpdate = DateTime.UtcNow.AddSeconds(updateTime);