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):
|
class AlertManager(component.Component):
|
||||||
def __init__(self, session):
|
def __init__(self, session):
|
||||||
log.debug("AlertManager initialized..")
|
log.debug("AlertManager initialized..")
|
||||||
component.Component.__init__(self, "AlertManager")
|
component.Component.__init__(self, "AlertManager", interval=50)
|
||||||
self.session = session
|
self.session = session
|
||||||
self.session.set_severity_level(lt.alert.severity_levels.info)
|
self.session.set_severity_level(lt.alert.severity_levels.info)
|
||||||
# handlers is a dictionary of lists {"alert_type": [handler1,h2,..]}
|
# handlers is a dictionary of lists {"alert_type": [handler1,h2,..]}
|
||||||
self.handlers = {}
|
self.handlers = {}
|
||||||
|
|
||||||
def start(self):
|
def update(self):
|
||||||
# Handle the alerts every 50 milliseconds
|
self.handle_alerts()
|
||||||
self.timer = gobject.timeout_add(50, self.handle_alerts)
|
|
||||||
|
|
||||||
def stop(self):
|
|
||||||
gobject.source_remove(self.timer)
|
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
self.stop()
|
|
||||||
del self.session
|
del self.session
|
||||||
del self.handlers
|
del self.handlers
|
||||||
|
|
||||||
|
|
|
@ -239,6 +239,9 @@ class TorrentManager(component.Component):
|
||||||
else:
|
else:
|
||||||
storage_mode = lt.storage_mode_t(1)
|
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:
|
try:
|
||||||
handle = self.session.add_torrent(
|
handle = self.session.add_torrent(
|
||||||
lt.torrent_info(filedump),
|
lt.torrent_info(filedump),
|
||||||
|
@ -251,12 +254,15 @@ class TorrentManager(component.Component):
|
||||||
|
|
||||||
if not handle or not handle.is_valid():
|
if not handle or not handle.is_valid():
|
||||||
# The torrent was not added to the session
|
# The torrent was not added to the session
|
||||||
|
component.resume("AlertManager")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Create a Torrent object
|
# Create a Torrent object
|
||||||
torrent = Torrent(filename, handle, options["compact_allocation"],
|
torrent = Torrent(filename, handle, options["compact_allocation"],
|
||||||
options["download_location"], total_uploaded, trackers)
|
options["download_location"], total_uploaded, trackers)
|
||||||
|
|
||||||
|
component.resume("AlertManager")
|
||||||
|
|
||||||
# Add the torrent object to the dictionary
|
# Add the torrent object to the dictionary
|
||||||
self.torrents[torrent.torrent_id] = torrent
|
self.torrents[torrent.torrent_id] = torrent
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue