From b8ce225ccce13fc2c57680ff36159dcfde3f2bac Mon Sep 17 00:00:00 2001 From: Flaminel Date: Thu, 20 Mar 2025 00:09:58 +0200 Subject: [PATCH] Fix Deluge service crashing when download is not found (#97) --- .../DownloadClient/Deluge/DelugeClient.cs | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/code/Infrastructure/Verticals/DownloadClient/Deluge/DelugeClient.cs b/code/Infrastructure/Verticals/DownloadClient/Deluge/DelugeClient.cs index 63048cb4..195c08b0 100644 --- a/code/Infrastructure/Verticals/DownloadClient/Deluge/DelugeClient.cs +++ b/code/Infrastructure/Verticals/DownloadClient/Deluge/DelugeClient.cs @@ -80,11 +80,24 @@ public sealed class DelugeClient public async Task GetTorrentStatus(string hash) { - return await SendRequest( - "web.get_torrent_status", - hash, - Fields - ); + try + { + return await SendRequest( + "web.get_torrent_status", + hash, + Fields + ); + } + catch (DelugeClientException e) + { + // Deluge returns an error when the torrent is not found + if (e.Message == "AttributeError: 'NoneType' object has no attribute 'call'") + { + return null; + } + + throw; + } } public async Task?> GetStatusForAllTorrents()