ratanakvlun / deluge-labelplus

81 stars 32 forks source link

Options set in Add Torrent Dialog are reset by LabelPlus #4

Closed nharrer closed 9 years ago

nharrer commented 10 years ago

core.py: on_torrent_added() is called upon adding a new torrent, which calls _set_torrent_label() with label ID_NONE, which then resets some torrents options. It potentially overwrites options which have been set in the Add Torrent dialog already.

Torrent added with the "Move Completed Location" option set: screen1

Option is reset as soon as the torrent is added: screen2

For a quick fix I changed on_torrent_added() to (changed if statement):

  @check_init
  def on_torrent_added(self, torrent_id):

    label_id = self._find_autolabel_match(torrent_id)
    if label_id and label_id != labelplus.common.label.ID_NONE:
      self._set_torrent_label(torrent_id, label_id)
      log.info("Setting torrent %r to label %r", torrent_id, label_id)

      self._timestamp["mappings_changed"] = datetime.datetime.now()

So _set_torrent_label(...) is not called if the new torrent has the default label ID_NONE.

ratanakvlun commented 10 years ago

Nice catch. I'll be sure to include this in the next version. Thanks for letting me know.

nharrer commented 10 years ago

All right. Excellent plugin btw. Two thumbs up!!