deluge-autoremoveplus icon indicating copy to clipboard operation
deluge-autoremoveplus copied to clipboard

clean torrent_states on torrent remove event

Open laur89 opened this issue 3 years ago • 0 comments

Otherwise the state file will continue growing indefinitely. Note atm we do clean it up if ARP itself removes the torrent, but not in cases where torrent deletion is triggered by 3rd party. We should remove current deletion (del self.torrent_states.config[tid] in remove_torrent()) and instead register a torrent removed event handler, eg what LabelPlus plugin does:

    deluge.component.get("EventManager").register_event_handler(
      "PreTorrentRemovedEvent", self.on_torrent_removed)


  def on_torrent_removed(self, torrent_id):

    if torrent_id in self._mappings:
      label_id = self._mappings[torrent_id]
      self._remove_torrent_label(torrent_id)
      log.debug("Removing torrent %r from label %r", torrent_id, label_id)

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

laur89 avatar Jan 23 '22 15:01 laur89