diff --git a/server/RdtClient.Service/Middleware/SabnzbdHandler.cs b/server/RdtClient.Service/Middleware/SabnzbdHandler.cs index 9dd7452..9446ff5 100644 --- a/server/RdtClient.Service/Middleware/SabnzbdHandler.cs +++ b/server/RdtClient.Service/Middleware/SabnzbdHandler.cs @@ -51,8 +51,17 @@ public class SabnzbdHandler(Authentication authentication, IHttpContextAccessor if (loginResult.Succeeded) { context.Succeed(requirement); + return; } + + // Invalid credentials provided + context.Fail(); + return; } + + // Authentication required but missing credentials + context.Fail(); + return; } } } diff --git a/server/RdtClient.Service/Services/DownloadClient.cs b/server/RdtClient.Service/Services/DownloadClient.cs index 6b68c70..fde9048 100644 --- a/server/RdtClient.Service/Services/DownloadClient.cs +++ b/server/RdtClient.Service/Services/DownloadClient.cs @@ -102,6 +102,7 @@ public class DownloadClient(Download download, Torrent torrent, String destinati await Downloader.Cancel(); } + Error = ex.Message; Finished = true; throw new($"An unexpected error occurred preparing download {download.Link} for torrent {torrent.RdName}: {ex.Message}"); diff --git a/server/RdtClient.Service/Services/RemoteService.cs b/server/RdtClient.Service/Services/RemoteService.cs index a985c9b..9a18a4e 100644 --- a/server/RdtClient.Service/Services/RemoteService.cs +++ b/server/RdtClient.Service/Services/RemoteService.cs @@ -48,25 +48,30 @@ public class RemoteService(IHubContext hub, Torrents torrents) RdSpeed = torrent.RdSpeed, RdSeeders = torrent.RdSeeders, Files = torrent.Files, - Downloads = torrent.Downloads.Select(download => new DownloadDto + Downloads = torrent.Downloads.Select(download => { - DownloadId = download.DownloadId, - TorrentId = download.TorrentId, - Path = download.Path, - Link = download.Link, - Added = download.Added, - DownloadQueued = download.DownloadQueued, - DownloadStarted = download.DownloadStarted, - DownloadFinished = download.DownloadFinished, - UnpackingQueued = download.UnpackingQueued, - UnpackingStarted = download.UnpackingStarted, - UnpackingFinished = download.UnpackingFinished, - Completed = download.Completed, - RetryCount = download.RetryCount, - Error = download.Error, - BytesTotal = download.BytesTotal, - BytesDone = download.BytesDone, - Speed = download.Speed + var (speed, bytesTotal, bytesDone) = torrents.GetDownloadStats(download.DownloadId); + + return new DownloadDto + { + DownloadId = download.DownloadId, + TorrentId = download.TorrentId, + Path = download.Path, + Link = download.Link, + Added = download.Added, + DownloadQueued = download.DownloadQueued, + DownloadStarted = download.DownloadStarted, + DownloadFinished = download.DownloadFinished, + UnpackingQueued = download.UnpackingQueued, + UnpackingStarted = download.UnpackingStarted, + UnpackingFinished = download.UnpackingFinished, + Completed = download.Completed, + RetryCount = download.RetryCount, + Error = download.Error, + BytesTotal = bytesTotal, + BytesDone = bytesDone, + Speed = speed + }; }).ToList() }).ToList(); await hub.Clients.All.SendCoreAsync("update", diff --git a/server/RdtClient.Service/Services/TorrentRunner.cs b/server/RdtClient.Service/Services/TorrentRunner.cs index 4c40837..82389d8 100644 --- a/server/RdtClient.Service/Services/TorrentRunner.cs +++ b/server/RdtClient.Service/Services/TorrentRunner.cs @@ -544,6 +544,7 @@ public class TorrentRunner(ILogger logger, Torrents torrents, Dow catch (Exception ex) { LogError($"Unable to start download: {ex.Message}", download, torrent); + continue; } Log($"Started download", download, torrent); diff --git a/server/RdtClient.Web/Controllers/TorrentsController.cs b/server/RdtClient.Web/Controllers/TorrentsController.cs index 37a815a..a2bb116 100644 --- a/server/RdtClient.Web/Controllers/TorrentsController.cs +++ b/server/RdtClient.Web/Controllers/TorrentsController.cs @@ -60,25 +60,30 @@ public class TorrentsController(ILogger logger, Torrents tor RdSpeed = torrent.RdSpeed, RdSeeders = torrent.RdSeeders, Files = torrent.Files, - Downloads = torrent.Downloads.Select(download => new DownloadDto + Downloads = torrent.Downloads.Select(download => { - DownloadId = download.DownloadId, - TorrentId = download.TorrentId, - Path = download.Path, - Link = download.Link, - Added = download.Added, - DownloadQueued = download.DownloadQueued, - DownloadStarted = download.DownloadStarted, - DownloadFinished = download.DownloadFinished, - UnpackingQueued = download.UnpackingQueued, - UnpackingStarted = download.UnpackingStarted, - UnpackingFinished = download.UnpackingFinished, - Completed = download.Completed, - RetryCount = download.RetryCount, - Error = download.Error, - BytesTotal = download.BytesTotal, - BytesDone = download.BytesDone, - Speed = download.Speed + var (speed, bytesTotal, bytesDone) = torrents.GetDownloadStats(download.DownloadId); + + return new DownloadDto + { + DownloadId = download.DownloadId, + TorrentId = download.TorrentId, + Path = download.Path, + Link = download.Link, + Added = download.Added, + DownloadQueued = download.DownloadQueued, + DownloadStarted = download.DownloadStarted, + DownloadFinished = download.DownloadFinished, + UnpackingQueued = download.UnpackingQueued, + UnpackingStarted = download.UnpackingStarted, + UnpackingFinished = download.UnpackingFinished, + Completed = download.Completed, + RetryCount = download.RetryCount, + Error = download.Error, + BytesTotal = bytesTotal, + BytesDone = bytesDone, + Speed = speed + }; }).ToList() }).ToList(); @@ -140,25 +145,30 @@ public class TorrentsController(ILogger logger, Torrents tor RdSpeed = torrent.RdSpeed, RdSeeders = torrent.RdSeeders, Files = torrent.Files, - Downloads = torrent.Downloads.Select(download => new DownloadDto + Downloads = torrent.Downloads.Select(download => { - DownloadId = download.DownloadId, - TorrentId = download.TorrentId, - Path = download.Path, - Link = download.Link, - Added = download.Added, - DownloadQueued = download.DownloadQueued, - DownloadStarted = download.DownloadStarted, - DownloadFinished = download.DownloadFinished, - UnpackingQueued = download.UnpackingQueued, - UnpackingStarted = download.UnpackingStarted, - UnpackingFinished = download.UnpackingFinished, - Completed = download.Completed, - RetryCount = download.RetryCount, - Error = download.Error, - BytesTotal = download.BytesTotal, - BytesDone = download.BytesDone, - Speed = download.Speed + var (speed, bytesTotal, bytesDone) = torrents.GetDownloadStats(download.DownloadId); + + return new DownloadDto + { + DownloadId = download.DownloadId, + TorrentId = download.TorrentId, + Path = download.Path, + Link = download.Link, + Added = download.Added, + DownloadQueued = download.DownloadQueued, + DownloadStarted = download.DownloadStarted, + DownloadFinished = download.DownloadFinished, + UnpackingQueued = download.UnpackingQueued, + UnpackingStarted = download.UnpackingStarted, + UnpackingFinished = download.UnpackingFinished, + Completed = download.Completed, + RetryCount = download.RetryCount, + Error = download.Error, + BytesTotal = bytesTotal, + BytesDone = bytesDone, + Speed = speed + }; }).ToList() };