Fix issue where we try to handle lt alerts for torrents that have not
had a Torrent object created for them yet.
This commit is contained in:
parent
f18b42b64d
commit
b87f68fcb6
|
@ -42,21 +42,16 @@ from deluge.log import LOG as log
|
|||
class AlertManager(component.Component):
|
||||
def __init__(self, session):
|
||||
log.debug("AlertManager initialized..")
|
||||
component.Component.__init__(self, "AlertManager")
|
||||
component.Component.__init__(self, "AlertManager", interval=50)
|
||||
self.session = session
|
||||
self.session.set_severity_level(lt.alert.severity_levels.info)
|
||||
# handlers is a dictionary of lists {"alert_type": [handler1,h2,..]}
|
||||
self.handlers = {}
|
||||
|
||||
def start(self):
|
||||
# Handle the alerts every 50 milliseconds
|
||||
self.timer = gobject.timeout_add(50, self.handle_alerts)
|
||||
|
||||
def stop(self):
|
||||
gobject.source_remove(self.timer)
|
||||
def update(self):
|
||||
self.handle_alerts()
|
||||
|
||||
def shutdown(self):
|
||||
self.stop()
|
||||
del self.session
|
||||
del self.handlers
|
||||
|
||||
|
|
|
@ -239,6 +239,9 @@ class TorrentManager(component.Component):
|
|||
else:
|
||||
storage_mode = lt.storage_mode_t(1)
|
||||
|
||||
# We need to pause the AlertManager momentarily to prevent alerts
|
||||
# for this torrent being generated before a Torrent object is created.
|
||||
component.pause("AlertManager")
|
||||
try:
|
||||
handle = self.session.add_torrent(
|
||||
lt.torrent_info(filedump),
|
||||
|
@ -251,12 +254,15 @@ class TorrentManager(component.Component):
|
|||
|
||||
if not handle or not handle.is_valid():
|
||||
# The torrent was not added to the session
|
||||
component.resume("AlertManager")
|
||||
return None
|
||||
|
||||
# Create a Torrent object
|
||||
torrent = Torrent(filename, handle, options["compact_allocation"],
|
||||
options["download_location"], total_uploaded, trackers)
|
||||
|
||||
|
||||
component.resume("AlertManager")
|
||||
|
||||
# Add the torrent object to the dictionary
|
||||
self.torrents[torrent.torrent_id] = torrent
|
||||
|
||||
|
|
Loading…
Reference in New Issue