mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-27 05:05:31 +00:00
Change core.remove_torrent to only accept one torrent_id, not a list
Added test for core.remove_torrent
This commit is contained in:
parent
0ca5a10d5e
commit
1b7be24bdf
4 changed files with 28 additions and 6 deletions
|
@ -308,10 +308,18 @@ class Core(component.Component):
|
||||||
return self.torrentmanager.add(magnet=uri, options=options)
|
return self.torrentmanager.add(magnet=uri, options=options)
|
||||||
|
|
||||||
@export
|
@export
|
||||||
def remove_torrent(self, torrent_ids, remove_data):
|
def remove_torrent(self, torrent_id, remove_data):
|
||||||
log.debug("Removing torrent %s from the core.", torrent_ids)
|
"""
|
||||||
for torrent_id in torrent_ids:
|
Removes a torrent from the session.
|
||||||
self.torrentmanager.remove(torrent_id, remove_data)
|
|
||||||
|
:param torrent_id: the torrent_id of the torrent to remove
|
||||||
|
:type torrent_id: string
|
||||||
|
:param remove_data: if True, remove the data associated with this torrent
|
||||||
|
:type remove_data: boolean
|
||||||
|
|
||||||
|
"""
|
||||||
|
log.debug("Removing torrent %s from the core.", torrent_id)
|
||||||
|
self.torrentmanager.remove(torrent_id, remove_data)
|
||||||
|
|
||||||
@export
|
@export
|
||||||
def get_stats(self):
|
def get_stats(self):
|
||||||
|
|
|
@ -60,7 +60,8 @@ class Command(BaseCommand):
|
||||||
for arg in args:
|
for arg in args:
|
||||||
torrent_ids.extend(self.console.match_torrent(arg))
|
torrent_ids.extend(self.console.match_torrent(arg))
|
||||||
|
|
||||||
return client.core.remove_torrent(torrent_ids, options['remove_data'])
|
for torrent_id in torrent_ids:
|
||||||
|
client.core.remove_torrent(torrent_id, options['remove_data'])
|
||||||
|
|
||||||
def complete(self, line):
|
def complete(self, line):
|
||||||
# We use the ConsoleUI torrent tab complete method
|
# We use the ConsoleUI torrent tab complete method
|
||||||
|
|
|
@ -82,7 +82,8 @@ class RemoveTorrentDialog(object):
|
||||||
button_data.set_label(pluralize_torrents(button_data.get_label()))
|
button_data.set_label(pluralize_torrents(button_data.get_label()))
|
||||||
|
|
||||||
def __remove_torrents(self, remove_data):
|
def __remove_torrents(self, remove_data):
|
||||||
client.core.remove_torrent(self.__torrent_ids, remove_data)
|
for torrent_id in self.__torrent_ids:
|
||||||
|
client.core.remove_torrent(torrent_id, remove_data)
|
||||||
# Unselect all to avoid issues with the selection changed event
|
# Unselect all to avoid issues with the selection changed event
|
||||||
component.get("TorrentView").treeview.get_selection().unselect_all()
|
component.get("TorrentView").treeview.get_selection().unselect_all()
|
||||||
|
|
||||||
|
|
|
@ -68,3 +68,15 @@ class CoreTestCase(unittest.TestCase):
|
||||||
|
|
||||||
torrent_id = self.core.add_torrent_magnet(uri, options)
|
torrent_id = self.core.add_torrent_magnet(uri, options)
|
||||||
self.assertEquals(torrent_id, info_hash)
|
self.assertEquals(torrent_id, info_hash)
|
||||||
|
|
||||||
|
def test_remove_torrent(self):
|
||||||
|
options = {}
|
||||||
|
filename = "../test.torrent"
|
||||||
|
import base64
|
||||||
|
torrent_id = self.core.add_torrent_file(filename, base64.encodestring(open(filename).read()), options)
|
||||||
|
|
||||||
|
self.core.remove_torrent(torrent_id, True)
|
||||||
|
|
||||||
|
self.assertEquals(len(self.core.get_session_state()), 0)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue