Fix issue in saving libtorrent session state

This commit is contained in:
Calum Lind 2011-12-15 16:10:21 +00:00
parent e49b7d5c23
commit 9d2b0101d6

View File

@ -136,9 +136,12 @@ class Core(component.Component):
self.__new_release = None self.__new_release = None
def stop(self): def stop(self):
log.debug("Core stopping...")
# Save the DHT state if necessary # Save the DHT state if necessary
if self.config["dht"]: if self.config["dht"]:
self.save_dht_state() self.save_dht_state()
# Save the libtorrent session state # Save the libtorrent session state
self.__save_session_state() self.__save_session_state()
@ -155,8 +158,9 @@ class Core(component.Component):
def __save_session_state(self): def __save_session_state(self):
"""Saves the libtorrent session state""" """Saves the libtorrent session state"""
try: try:
open(deluge.configmanager.get_config_dir("session.state"), "wb").write( lt_data = open(deluge.configmanager.get_config_dir("session.state"), "wb")
lt.bencode(self.session.state())) lt_data.write(lt.bencode(self.session.save_state()))
lt_data.close()
except Exception, e: except Exception, e:
log.warning("Failed to save lt state: %s", e) log.warning("Failed to save lt state: %s", e)