deluge-autoremoveplus
deluge-autoremoveplus copied to clipboard
clean torrent_states on torrent remove event
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()