Author: andar

Revision: 5223

Log:
        Fix per-torrent move on completed stuff - patch from Plisk

Diff:
Modified: trunk/deluge/core/core.py
===================================================================
--- trunk/deluge/core/core.py   2009-05-01 20:21:25 UTC (rev 5222)
+++ trunk/deluge/core/core.py   2009-05-02 02:07:11 UTC (rev 5223)
@@ -564,14 +564,14 @@
         return self.torrentmanager[torrent_id].set_remove_at_ratio(value)
 
     @export
-    def set_torrent_move_on_completed(self, torrent_id, value):
+    def set_torrent_move_completed(self, torrent_id, value):
         """Sets the torrent to be moved when completed"""
-        return self.torrentmanager[torrent_id].set_move_on_completed(value)
+        return self.torrentmanager[torrent_id].set_move_completed(value)
 
     @export
-    def set_torrent_move_on_completed_path(self, torrent_id, value):
+    def set_torrent_move_completed_path(self, torrent_id, value):
         """Sets the path for the torrent to be moved when completed"""
-        return 
self.torrentmanager[torrent_id].set_move_on_completed_path(value)
+        return self.torrentmanager[torrent_id].set_move_completed_path(value)
 
     @export
     def block_ip_range(self, range):

Modified: trunk/deluge/core/torrent.py
===================================================================
--- trunk/deluge/core/torrent.py        2009-05-01 20:21:25 UTC (rev 5222)
+++ trunk/deluge/core/torrent.py        2009-05-02 02:07:11 UTC (rev 5223)
@@ -180,6 +180,7 @@
 
         # Various torrent options
         self.handle.resolve_countries(True)
+
         self.set_options(self.options)
 
         # Status message holds error info about the torrent
@@ -272,6 +273,12 @@
     def set_remove_at_ratio(self, remove_at_ratio):
         self.options["remove_at_ratio"] = remove_at_ratio
 
+    def set_move_completed(self, move_completed):
+        self.options["move_completed"] = move_completed
+
+    def set_move_completed_path(self, move_completed_path):
+        self.options["move_completed_path"] = move_completed_path
+
     def set_file_priorities(self, file_priorities):
         if len(file_priorities) != len(self.files):
             log.debug("file_priorities len != num_files")

Modified: trunk/deluge/core/torrentmanager.py
===================================================================
--- trunk/deluge/core/torrentmanager.py 2009-05-01 20:21:25 UTC (rev 5222)
+++ trunk/deluge/core/torrentmanager.py 2009-05-02 02:07:11 UTC (rev 5223)
@@ -73,6 +73,8 @@
             stop_ratio=2.00,
             stop_at_ratio=False,
             remove_at_ratio=False,
+            move_completed=False,
+            move_completed_path=None,
             magnet=None,
             time_added=-1
         ):
@@ -99,6 +101,8 @@
         self.stop_ratio = stop_ratio
         self.stop_at_ratio = stop_at_ratio
         self.remove_at_ratio = remove_at_ratio
+        self.move_completed = move_completed
+        self.move_completed_path = move_completed_path
 
 class TorrentManagerState:
     def __init__(self):
@@ -296,6 +300,8 @@
             options["compact_allocation"] = state.compact
             options["download_location"] = state.save_path
             options["auto_managed"] = state.auto_managed
+            options["move_completed"] = state.move_completed
+            options["move_completed_path"] = state.move_completed_path
             options["add_paused"] = state.paused
 
             if not state.magnet:
@@ -477,10 +483,11 @@
 
         # Try to use an old state
         try:
-            if dir(state.torrents[0]) != dir(TorrentState()):
-                for attr in (set(dir(TorrentState())) - 
set(dir(state.torrents[0]))):
+            state_tmp = TorrentState()
+            if dir(state.torrents[0]) != dir(state_tmp):
+                for attr in (set(dir(state_tmp)) - 
set(dir(state.torrents[0]))):
                     for s in state.torrents:
-                        setattr(s, attr, getattr(TorrentState(), attr, None))
+                        setattr(s, attr, getattr(state_tmp, attr, None))
         except Exception, e:
             log.warning("Unable to update state file to a compatible version: 
%s", e)
 
@@ -533,6 +540,8 @@
                 torrent.options["stop_ratio"],
                 torrent.options["stop_at_ratio"],
                 torrent.options["remove_at_ratio"],
+                torrent.options["move_completed"],
+                torrent.options["move_completed_path"],
                 torrent.magnet,
                 torrent.time_added
             )

Modified: trunk/deluge/ui/gtkui/options_tab.py
===================================================================
--- trunk/deluge/ui/gtkui/options_tab.py        2009-05-01 20:21:25 UTC (rev 
5222)
+++ trunk/deluge/ui/gtkui/options_tab.py        2009-05-02 02:07:11 UTC (rev 
5223)
@@ -165,13 +165,13 @@
         if self.chk_remove_at_ratio.get_active() != 
self.prev_status["remove_at_ratio"]:
             client.core.set_torrent_remove_at_ratio(self.prev_torrent_id, 
self.chk_remove_at_ratio.get_active())
         if self.chk_move_completed.get_active() != 
self.prev_status["move_on_completed"]:
-            client.core.set_torrent_move_on_completed(self.prev_torrent_id, 
self.chk_move_completed.get_active())
-            if self.chk_move_completed.get_active():
-                if client.is_localhost():
-                    path = self.filechooser_move_completed.get_current_folder()
-                else:
-                    path = self.entry_move_completed.get_text()
-                
client.core.set_torrent_move_on_completed_path(self.prev_torrent_id, path)
+            client.core.set_torrent_move_completed(self.prev_torrent_id, 
self.chk_move_completed.get_active())
+        if self.chk_move_completed.get_active():
+            if client.is_localhost():
+                path = self.filechooser_move_completed.get_current_folder()
+            else:
+                path = self.entry_move_completed.get_text()
+            client.core.set_torrent_move_completed_path(self.prev_torrent_id, 
path)
 
 
     def _on_button_edit_trackers_clicked(self, button):



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to