diff --git a/deluge/core/core.py b/deluge/core/core.py index a79dda0f8..907c6bbba 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -308,10 +308,18 @@ class Core(component.Component): return self.torrentmanager.add(magnet=uri, options=options) @export - def remove_torrent(self, torrent_ids, remove_data): - log.debug("Removing torrent %s from the core.", torrent_ids) - for torrent_id in torrent_ids: - self.torrentmanager.remove(torrent_id, remove_data) + def remove_torrent(self, torrent_id, remove_data): + """ + Removes a torrent from the session. + + :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 def get_stats(self): diff --git a/deluge/ui/console/commands/rm.py b/deluge/ui/console/commands/rm.py index 38cba9fcc..2037a399e 100644 --- a/deluge/ui/console/commands/rm.py +++ b/deluge/ui/console/commands/rm.py @@ -60,7 +60,8 @@ class Command(BaseCommand): for arg in args: 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): # We use the ConsoleUI torrent tab complete method diff --git a/deluge/ui/gtkui/removetorrentdialog.py b/deluge/ui/gtkui/removetorrentdialog.py index bf3be69e3..49fc42361 100644 --- a/deluge/ui/gtkui/removetorrentdialog.py +++ b/deluge/ui/gtkui/removetorrentdialog.py @@ -82,7 +82,8 @@ class RemoveTorrentDialog(object): button_data.set_label(pluralize_torrents(button_data.get_label())) 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 component.get("TorrentView").treeview.get_selection().unselect_all() diff --git a/tests/test_core.py b/tests/test_core.py index 1dcdc7e5d..83dcf5ccc 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -68,3 +68,15 @@ class CoreTestCase(unittest.TestCase): torrent_id = self.core.add_torrent_magnet(uri, options) 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) + +