Remove unneeded dht saving state to separate file
The dht state is now saved by default in the session state by libtorrent
This commit is contained in:
parent
a754f1303f
commit
bc91804996
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue