Add some error handling for calculating progress for qBittorrent.
Some checks failed
Docker Image CI / build (push) Has been cancelled
Some checks failed
Docker Image CI / build (push) Has been cancelled
This commit is contained in:
parent
2bf1c997d8
commit
86eaccd439
5 changed files with 29 additions and 9 deletions
|
|
@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [2.0.79] - 2024-06-03
|
||||
### Changed
|
||||
- Fixed issue with qBittorrent progress sometimes throwing errors.
|
||||
|
||||
## [2.0.78] - 2024-05-04
|
||||
### Changed
|
||||
- Fixed Aria2c download path issue when a category is set.
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@
|
|||
<a class="navbar-item" routerLink="profile"> Profile </a>
|
||||
<a class="navbar-item" (click)="logout()"> Logout </a>
|
||||
<hr class="navbar-divider" />
|
||||
<a href="https://github.com/rogerfar/rdt-client" target="_blank" class="navbar-item">Version 2.0.78</a>
|
||||
<a href="https://github.com/rogerfar/rdt-client" target="_blank" class="navbar-item">Version 2.0.79</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "rdt-client",
|
||||
"version": "2.0.78",
|
||||
"version": "2.0.79",
|
||||
"description": "This is a web interface to manage your torrents on Real-Debrid.",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
|
|
|
|||
|
|
@ -211,20 +211,36 @@ public class QBittorrent(ILogger<QBittorrent> logger, Settings settings, Authent
|
|||
torrentPath = Path.Combine(downloadPath, torrent.RdName) + Path.DirectorySeparatorChar;
|
||||
}
|
||||
|
||||
var rdProgress = (torrent.RdProgress ?? 0) / 100.0m;
|
||||
var bytesTotal = torrent.RdSize ?? 1;
|
||||
var bytesDone = (Int64)(bytesTotal * rdProgress);
|
||||
var speed = torrent.RdSpeed ?? 0;
|
||||
Int64 bytesDone = 0;
|
||||
Int64 bytesTotal = 0;
|
||||
Int64 speed = 0;
|
||||
Int64 rdProgress = 0;
|
||||
try
|
||||
{
|
||||
rdProgress = (Int64) ((torrent.RdProgress ?? 0) / 100.0m);
|
||||
bytesTotal = torrent.RdSize ?? 1;
|
||||
bytesDone = bytesTotal * rdProgress;
|
||||
speed = torrent.RdSpeed ?? 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, $"""
|
||||
Error calculating progress:
|
||||
RdProgress: {torrent.RdProgress}
|
||||
RdSize: {torrent.RdSize}
|
||||
RdSpeed: {torrent.RdSpeed}
|
||||
""");
|
||||
}
|
||||
|
||||
if (torrent.Downloads.Count > 0)
|
||||
{
|
||||
bytesDone = torrent.Downloads.Sum(m => m.BytesDone);
|
||||
bytesTotal = torrent.Downloads.Sum(m => m.BytesTotal);
|
||||
speed = (Int32) torrent.Downloads.Average(m => m.Speed);
|
||||
downloadProgress = bytesTotal > 0 ? (Decimal)bytesDone / bytesTotal : 0;
|
||||
downloadProgress = bytesTotal > 0 ? (Decimal) bytesDone / bytesTotal : 0;
|
||||
}
|
||||
|
||||
var progress = (rdProgress + downloadProgress) / 2m;
|
||||
var progress = (Int64) ((rdProgress + downloadProgress) / 2m);
|
||||
|
||||
var result = new TorrentInfo
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<TargetFramework>net8.0</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<UserSecretsId>94c24cba-f03f-4453-a671-3640b517c573</UserSecretsId>
|
||||
<Version>2.0.78</Version>
|
||||
<Version>2.0.79</Version>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<LangVersion>latest</LangVersion>
|
||||
|
|
|
|||
Loading…
Reference in a new issue