Module: deluge
Branch: master
Commit: bba825703b30f675fc4bc4edc1ebee1be402bf18

Author: Chase Sterling <[email protected]>
Date:   Tue Apr 13 15:21:49 2010 -0400

refs #1180, old label preferences are removed from torrent when new label is set

---

 deluge/plugins/label/label/core.py |   35 ++++++++++++++++++++++++++++++-----
 1 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/deluge/plugins/label/label/core.py 
b/deluge/plugins/label/label/core.py
index 34447cd..478dac5 100644
--- a/deluge/plugins/label/label/core.py
+++ b/deluge/plugins/label/label/core.py
@@ -225,6 +225,31 @@ class Core(CorePluginBase):
                 }
             )
 
+    def _unset_torrent_options(self, torrent_id, label_id):
+        options = self.labels[label_id]
+        torrent = self.torrents[torrent_id]
+
+        if options["apply_max"]:
+            
torrent.set_max_download_speed(self.core_cfg.config["max_download_speed_per_torrent"])
+            
torrent.set_max_upload_speed(self.core_cfg.config["max_upload_speed_per_torrent"])
+            
torrent.set_max_connections(self.core_cfg.config["max_connections_per_torrent"])
+            
torrent.set_max_upload_slots(self.core_cfg.config["max_upload_slots_per_torrent"])
+            
torrent.set_prioritize_first_last(self.core_cfg.config["prioritize_first_last_pieces"])
+
+        if options["apply_queue"]:
+            torrent.set_auto_managed(self.core_cfg.config['auto_managed'])
+            
torrent.set_stop_at_ratio(self.core_cfg.config['stop_seed_at_ratio'])
+            torrent.set_stop_ratio(self.core_cfg.config['stop_seed_ratio'])
+            
torrent.set_remove_at_ratio(self.core_cfg.config['remove_seed_at_ratio'])
+
+        if options["apply_move_completed"]:
+            torrent.set_options(
+                {
+                    "move_completed": self.core_cfg.config["move_completed"],
+                    "move_completed_path": 
self.core_cfg.config["move_completed_path"]
+                }
+            )
+
     def _has_auto_match(self, torrent ,label_options):
         """match for auto_add fields"""
         for tracker_match in label_options["auto_add_trackers"]:
@@ -287,11 +312,11 @@ class Core(CorePluginBase):
         CheckInput((not label_id) or (label_id in self.labels)  , _("Unknown 
Label"))
         CheckInput(torrent_id in self.torrents  , _("Unknown Torrent"))
 
-        if not label_id:
-            if torrent_id in self.torrent_labels:
-                del self.torrent_labels[torrent_id]
-                self.clean_config()
-        else:
+        if torrent_id in self.torrent_labels:
+            self._unset_torrent_options(torrent_id, 
self.torrent_labels[torrent_id])
+            del self.torrent_labels[torrent_id]
+            self.clean_config()
+        if label_id:
             self.torrent_labels[torrent_id] = label_id
             self._set_torrent_options(torrent_id, label_id)
 

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