From bc91804996788b0f4b902dbacc349b66bd7311f6 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Wed, 15 May 2013 16:20:30 +0100 Subject: [PATCH] Remove unneeded dht saving state to separate file The dht state is now saved by default in the session state by libtorrent --- deluge/core/core.py | 13 ------------- deluge/core/preferencesmanager.py | 14 +------------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/deluge/core/core.py b/deluge/core/core.py index 5b2ba70bd..dd8a76b2b 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -137,10 +137,6 @@ class Core(component.Component): def stop(self): log.debug("Core stopping...") - # Save the DHT state if necessary - if self.config["dht"]: - self.save_dht_state() - # Save the libtorrent session state self.__save_session_state() @@ -170,15 +166,6 @@ class Core(component.Component): except Exception, e: log.warning("Failed to load lt state: %s", e) - def save_dht_state(self): - """Saves the dht state to a file""" - try: - dht_data = open(deluge.configmanager.get_config_dir("dht.state"), "wb") - dht_data.write(lt.bencode(self.session.dht_state())) - dht_data.close() - except Exception, e: - log.warning("Failed to save dht state: %s", e) - def get_new_release(self): log.debug("get_new_release") from urllib2 import urlopen diff --git a/deluge/core/preferencesmanager.py b/deluge/core/preferencesmanager.py index f22c6b23d..a085d2c99 100644 --- a/deluge/core/preferencesmanager.py +++ b/deluge/core/preferencesmanager.py @@ -244,24 +244,12 @@ class PreferencesManager(component.Component): def _on_set_dht(self, key, value): log.debug("dht value set to %s", value) - state_file = deluge.configmanager.get_config_dir("dht.state") if value: - state = None - try: - state = lt.bdecode(open(state_file, "rb").read()) - except Exception, e: - log.warning("Unable to read DHT state file: %s", e) - - try: - self.session.start_dht(state) - except Exception, e: - log.warning("Restoring old DHT state failed: %s", e) - self.session.start_dht(None) + self.session.start_dht() self.session.add_dht_router("router.bittorrent.com", 6881) self.session.add_dht_router("router.utorrent.com", 6881) self.session.add_dht_router("router.bitcomet.com", 6881) else: - self.core.save_dht_state() self.session.stop_dht() def _on_set_upnp(self, key, value):