Merge pull request #930 from omgbeez/upstream/downloads-fix

Fix broken download status in the UI
This commit is contained in:
Roger Far 2026-02-21 15:18:08 -07:00 committed by GitHub
commit f4e1cf4717
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 80 additions and 54 deletions

View file

@ -51,8 +51,17 @@ public class SabnzbdHandler(Authentication authentication, IHttpContextAccessor
if (loginResult.Succeeded) if (loginResult.Succeeded)
{ {
context.Succeed(requirement); context.Succeed(requirement);
} return;
} }
// Invalid credentials provided
context.Fail();
return;
}
// Authentication required but missing credentials
context.Fail();
return;
} }
} }
} }

View file

@ -102,6 +102,7 @@ public class DownloadClient(Download download, Torrent torrent, String destinati
await Downloader.Cancel(); await Downloader.Cancel();
} }
Error = ex.Message;
Finished = true; Finished = true;
throw new($"An unexpected error occurred preparing download {download.Link} for torrent {torrent.RdName}: {ex.Message}"); throw new($"An unexpected error occurred preparing download {download.Link} for torrent {torrent.RdName}: {ex.Message}");

View file

@ -48,7 +48,11 @@ public class RemoteService(IHubContext<RdtHub> hub, Torrents torrents)
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 =>
{
var (speed, bytesTotal, bytesDone) = torrents.GetDownloadStats(download.DownloadId);
return new DownloadDto
{ {
DownloadId = download.DownloadId, DownloadId = download.DownloadId,
TorrentId = download.TorrentId, TorrentId = download.TorrentId,
@ -64,9 +68,10 @@ public class RemoteService(IHubContext<RdtHub> hub, Torrents torrents)
Completed = download.Completed, Completed = download.Completed,
RetryCount = download.RetryCount, RetryCount = download.RetryCount,
Error = download.Error, Error = download.Error,
BytesTotal = download.BytesTotal, BytesTotal = bytesTotal,
BytesDone = download.BytesDone, BytesDone = bytesDone,
Speed = download.Speed Speed = speed
};
}).ToList() }).ToList()
}).ToList(); }).ToList();
await hub.Clients.All.SendCoreAsync("update", await hub.Clients.All.SendCoreAsync("update",

View file

@ -544,6 +544,7 @@ public class TorrentRunner(ILogger<TorrentRunner> logger, Torrents torrents, Dow
catch (Exception ex) catch (Exception ex)
{ {
LogError($"Unable to start download: {ex.Message}", download, torrent); LogError($"Unable to start download: {ex.Message}", download, torrent);
continue;
} }
Log($"Started download", download, torrent); Log($"Started download", download, torrent);

View file

@ -60,7 +60,11 @@ 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 =>
{
var (speed, bytesTotal, bytesDone) = torrents.GetDownloadStats(download.DownloadId);
return new DownloadDto
{ {
DownloadId = download.DownloadId, DownloadId = download.DownloadId,
TorrentId = download.TorrentId, TorrentId = download.TorrentId,
@ -76,9 +80,10 @@ public class TorrentsController(ILogger<TorrentsController> logger, Torrents tor
Completed = download.Completed, Completed = download.Completed,
RetryCount = download.RetryCount, RetryCount = download.RetryCount,
Error = download.Error, Error = download.Error,
BytesTotal = download.BytesTotal, BytesTotal = bytesTotal,
BytesDone = download.BytesDone, BytesDone = bytesDone,
Speed = download.Speed Speed = speed
};
}).ToList() }).ToList()
}).ToList(); }).ToList();
@ -140,7 +145,11 @@ 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 =>
{
var (speed, bytesTotal, bytesDone) = torrents.GetDownloadStats(download.DownloadId);
return new DownloadDto
{ {
DownloadId = download.DownloadId, DownloadId = download.DownloadId,
TorrentId = download.TorrentId, TorrentId = download.TorrentId,
@ -156,9 +165,10 @@ public class TorrentsController(ILogger<TorrentsController> logger, Torrents tor
Completed = download.Completed, Completed = download.Completed,
RetryCount = download.RetryCount, RetryCount = download.RetryCount,
Error = download.Error, Error = download.Error,
BytesTotal = download.BytesTotal, BytesTotal = bytesTotal,
BytesDone = download.BytesDone, BytesDone = bytesDone,
Speed = download.Speed Speed = speed
};
}).ToList() }).ToList()
}; };