summaryrefslogtreecommitdiffstats
path: root/deluge
diff options
context:
space:
mode:
authorDjLegolas <djlegolas@protonmail.com>2022-01-21 02:40:08 +0200
committerCalum Lind <calumlind+deluge@gmail.com>2022-03-02 13:00:45 +0000
commit7fa0af344618aee141951d7541d14097460d00b5 (patch)
tree507284268f9473ab25b879f5e6ebe5a453df2759 /deluge
parenta9543485672eaa1a5ba773764c89e4fcec3bada3 (diff)
downloaddeluge-7fa0af344618aee141951d7541d14097460d00b5.tar.gz
deluge-7fa0af344618aee141951d7541d14097460d00b5.tar.bz2
deluge-7fa0af344618aee141951d7541d14097460d00b5.zip
[Core] Fixed KeyError in sessionproxy after torrent delete
When several torrents are being removed from session, an exception was being raised in a callback function `on_status` with the `torrent_id` of one (or more) of the removed torrents. Now we will catch when the torrent does not exist anymore and print a debug log about it. Closes: https://dev.deluge-torrent.org/ticket/3498 Closes: https://github.com/deluge-torrent/deluge/pull/341
Diffstat (limited to 'deluge')
-rw-r--r--deluge/ui/sessionproxy.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/deluge/ui/sessionproxy.py b/deluge/ui/sessionproxy.py
index a79144e0c..b50ba6c3d 100644
--- a/deluge/ui/sessionproxy.py
+++ b/deluge/ui/sessionproxy.py
@@ -145,11 +145,17 @@ class SessionProxy(component.Component):
def on_status(result, torrent_id):
t = time()
- self.torrents[torrent_id][0] = t
- self.torrents[torrent_id][1].update(result)
- for key in keys_to_get:
- self.cache_times[torrent_id][key] = t
- return self.create_status_dict([torrent_id], keys)[torrent_id]
+ try:
+ self.torrents[torrent_id][0] = t
+ self.torrents[torrent_id][1].update(result)
+ for key in keys_to_get:
+ self.cache_times[torrent_id][key] = t
+ return self.create_status_dict([torrent_id], keys)[torrent_id]
+ except KeyError:
+ log.debug(
+ f'Status missing for torrent (removed?): {torrent_id}'
+ )
+ return {}
return d.addCallback(on_status, torrent_id)
else: