Skip to content

Commit

Permalink
refs #1180, old label preferences are removed from torrent when new l…
Browse files Browse the repository at this point in the history
…abel is set
  • Loading branch information
gazpachoking committed Apr 13, 2010
1 parent 3f3f7bb commit bba8257
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions deluge/plugins/label/label/core.py
Expand Up @@ -225,6 +225,31 @@ def _set_torrent_options(self, torrent_id, label_id):
}
)

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"]:
Expand Down Expand Up @@ -287,11 +312,11 @@ def set_torrent(self, torrent_id , label_id):
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)

Expand Down

0 comments on commit bba8257

Please sign in to comment.