Author: andar
Revision: 5539
Log:
Change core.remove_torrent to only accept one torrent_id, not a list
Added test for core.remove_torrent
Diff:
Modified: trunk/deluge/core/core.py
===================================================================
--- trunk/deluge/core/core.py 2009-07-23 00:46:23 UTC (rev 5538)
+++ trunk/deluge/core/core.py 2009-07-23 04:14:08 UTC (rev 5539)
@@ -308,11 +308,19 @@
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):
"""
Modified: trunk/deluge/ui/console/commands/rm.py
===================================================================
--- trunk/deluge/ui/console/commands/rm.py 2009-07-23 00:46:23 UTC (rev
5538)
+++ trunk/deluge/ui/console/commands/rm.py 2009-07-23 04:14:08 UTC (rev
5539)
@@ -60,7 +60,8 @@
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
Modified: trunk/deluge/ui/gtkui/removetorrentdialog.py
===================================================================
--- trunk/deluge/ui/gtkui/removetorrentdialog.py 2009-07-23 00:46:23 UTC
(rev 5538)
+++ trunk/deluge/ui/gtkui/removetorrentdialog.py 2009-07-23 04:14:08 UTC
(rev 5539)
@@ -82,7 +82,8 @@
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()
Modified: trunk/tests/test_core.py
===================================================================
--- trunk/tests/test_core.py 2009-07-23 00:46:23 UTC (rev 5538)
+++ trunk/tests/test_core.py 2009-07-23 04:14:08 UTC (rev 5539)
@@ -68,3 +68,15 @@
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)
+
+
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---