Change torrent_add_file() method in core to return a boolean value based
on the success of the torrent add. Removed the torrent_add_failed() signal from core.
This commit is contained in:
parent
be5855dcd6
commit
b187d02c94
|
@ -96,7 +96,7 @@ class Core(dbus.service.Object):
|
|||
del self.session
|
||||
|
||||
@dbus.service.method(dbus_interface="org.deluge_torrent.Deluge",
|
||||
in_signature="say", out_signature="")
|
||||
in_signature="say", out_signature="b")
|
||||
def add_torrent_file(self, filename, filedump):
|
||||
"""Adds a torrent file to the libtorrent session
|
||||
This requires the torrents filename and a dump of it's content
|
||||
|
@ -109,8 +109,10 @@ class Core(dbus.service.Object):
|
|||
if torrent_id is not None:
|
||||
# Emit the torrent_added signal
|
||||
self.torrent_added(torrent_id)
|
||||
return True
|
||||
else:
|
||||
self.torrent_add_failed()
|
||||
# Return False because the torrent was not added successfully
|
||||
return False
|
||||
|
||||
@dbus.service.method(dbus_interface="org.deluge_torrent.Deluge",
|
||||
in_signature="s", out_signature="")
|
||||
|
@ -177,12 +179,6 @@ class Core(dbus.service.Object):
|
|||
"""Emitted when a new torrent is added to the core"""
|
||||
log.debug("torrent_added signal emitted")
|
||||
|
||||
@dbus.service.signal(dbus_interface="org.deluge_torrent.Deluge",
|
||||
signature="")
|
||||
def torrent_add_failed(self):
|
||||
"""Emitted when a new torrent fails addition to the session"""
|
||||
log.debug("torrent_add_failed signal emitted")
|
||||
|
||||
@dbus.service.signal(dbus_interface="org.deluge_torrent.Deluge",
|
||||
signature="s")
|
||||
def torrent_removed(self, torrent_id):
|
||||
|
|
|
@ -85,8 +85,11 @@ def add_torrent_file(torrent_files):
|
|||
f = open(torrent_file, "rb")
|
||||
# Get the filename because the core doesn't want a path.
|
||||
(path, filename) = os.path.split(torrent_file)
|
||||
core.add_torrent_file(filename, f.read())
|
||||
result = core.add_torrent_file(filename, f.read())
|
||||
f.close()
|
||||
if result is False:
|
||||
# The torrent was not added successfully.
|
||||
log.warning("Torrent %s was not added successfully.", filename)
|
||||
|
||||
def remove_torrent(torrent_ids):
|
||||
"""Removes torrent_ids from the core.. Expects a list of torrent_ids"""
|
||||
|
@ -107,15 +110,6 @@ def resume_torrent(torrent_ids):
|
|||
for torrent_id in torrent_ids:
|
||||
core.resume_torrent(torrent_id)
|
||||
|
||||
def get_torrent_info(core, torrent_id):
|
||||
"""Builds the info dictionary and returns it"""
|
||||
info = core.get_torrent_info(torrent_id)
|
||||
# Join the array of bytes into a string for pickle to read
|
||||
info = "".join(chr(b) for b in info)
|
||||
# De-serialize the object
|
||||
info = pickle.loads(info)
|
||||
return info
|
||||
|
||||
def get_torrent_status(core, torrent_id, keys):
|
||||
"""Builds the status dictionary and returns it"""
|
||||
status = core.get_torrent_status(torrent_id, keys)
|
||||
|
|
Loading…
Reference in New Issue