Skip to content

Commit b8ce225

Browse files
authored
Fix Deluge service crashing when download is not found (#97)
1 parent f21f738 commit b8ce225

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

code/Infrastructure/Verticals/DownloadClient/Deluge/DelugeClient.cs

+18-5
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,24 @@ public async Task<List<DelugeTorrentExtended>> ListTorrentsExtended(Dictionary<s
8080

8181
public async Task<TorrentStatus?> GetTorrentStatus(string hash)
8282
{
83-
return await SendRequest<TorrentStatus?>(
84-
"web.get_torrent_status",
85-
hash,
86-
Fields
87-
);
83+
try
84+
{
85+
return await SendRequest<TorrentStatus?>(
86+
"web.get_torrent_status",
87+
hash,
88+
Fields
89+
);
90+
}
91+
catch (DelugeClientException e)
92+
{
93+
// Deluge returns an error when the torrent is not found
94+
if (e.Message == "AttributeError: 'NoneType' object has no attribute 'call'")
95+
{
96+
return null;
97+
}
98+
99+
throw;
100+
}
88101
}
89102

90103
public async Task<List<TorrentStatus>?> GetStatusForAllTorrents()

0 commit comments

Comments
 (0)