Skip to content

Commit

Permalink
Fixed download progress reporting to the qBittorrent API.
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerfar committed Sep 3, 2024
1 parent fae9832 commit cc52f5f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions server/RdtClient.Service/Services/QBittorrent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public async Task<IList<TorrentInfo>> TorrentInfo()

var prio = 0;

Decimal downloadProgress = 0;
Double downloadProgress = 0;

foreach (var torrent in allTorrents)
{
Expand All @@ -214,12 +214,12 @@ public async Task<IList<TorrentInfo>> TorrentInfo()
Int64 bytesDone = 0;
Int64 bytesTotal = 0;
Int64 speed = 0;
Int64 rdProgress = 0;
Double rdProgress = 0;
try
{
rdProgress = (Int64) ((torrent.RdProgress ?? 0) / 100.0m);
rdProgress = (torrent.RdProgress ?? 0.0) / 100.0;
bytesTotal = torrent.RdSize ?? 1;
bytesDone = bytesTotal * rdProgress;
bytesDone = (Int64) (bytesTotal * rdProgress);
speed = torrent.RdSpeed ?? 0;
}
catch (Exception ex)
Expand All @@ -237,10 +237,10 @@ public async Task<IList<TorrentInfo>> TorrentInfo()
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 ? (Double) bytesDone / bytesTotal : 0;
}

var progress = (Int64) ((rdProgress + downloadProgress) / 2m);
var progress = (rdProgress + downloadProgress) / 2.0;

var result = new TorrentInfo
{
Expand Down
2 changes: 1 addition & 1 deletion server/RdtClient.Web/Controllers/QBittorrentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public ActionResult AppSetPreferences()
[HttpPost]
public ActionResult<AppPreferences> AppDefaultSavePath()
{
var result = Service.Services.Settings.AppDefaultSavePath;
var result = Settings.AppDefaultSavePath;
return Ok(result);
}

Expand Down

0 comments on commit cc52f5f

Please sign in to comment.