Use deluge.configmanager.get_config_dir() to find the state folder location since the 'state_location' key in the config may be wrong if the config folder has changed
This commit is contained in:
parent
8c23baa4e2
commit
054ab20402
|
@ -500,7 +500,7 @@ class TorrentManager(component.Component):
|
||||||
try:
|
try:
|
||||||
log.debug("Opening torrent state file for load.")
|
log.debug("Opening torrent state file for load.")
|
||||||
state_file = open(
|
state_file = open(
|
||||||
os.path.join(self.config["state_location"], "torrents.state"), "rb")
|
os.path.join(deluge.configmanager.get_config_dir(), "state", "torrents.state"), "rb")
|
||||||
state = cPickle.load(state_file)
|
state = cPickle.load(state_file)
|
||||||
state_file.close()
|
state_file.close()
|
||||||
except (EOFError, IOError, Exception), e:
|
except (EOFError, IOError, Exception), e:
|
||||||
|
@ -569,7 +569,7 @@ class TorrentManager(component.Component):
|
||||||
try:
|
try:
|
||||||
log.debug("Saving torrent state file.")
|
log.debug("Saving torrent state file.")
|
||||||
state_file = open(
|
state_file = open(
|
||||||
os.path.join(self.config["state_location"], "torrents.state.new"),
|
os.path.join(deluge.configmanager.get_config_dir(), "state", "torrents.state.new"),
|
||||||
"wb")
|
"wb")
|
||||||
cPickle.dump(state, state_file)
|
cPickle.dump(state, state_file)
|
||||||
state_file.flush()
|
state_file.flush()
|
||||||
|
@ -582,8 +582,8 @@ class TorrentManager(component.Component):
|
||||||
# We have to move the 'torrents.state.new' file to 'torrents.state'
|
# We have to move the 'torrents.state.new' file to 'torrents.state'
|
||||||
try:
|
try:
|
||||||
shutil.move(
|
shutil.move(
|
||||||
os.path.join(self.config["state_location"], "torrents.state.new"),
|
os.path.join(deluge.configmanager.get_config_dir(), "state", "torrents.state.new"),
|
||||||
os.path.join(self.config["state_location"], "torrents.state"))
|
os.path.join(deluge.configmanager.get_config_dir(), "state", "torrents.state"))
|
||||||
except IOError:
|
except IOError:
|
||||||
log.warning("Unable to save state file.")
|
log.warning("Unable to save state file.")
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in New Issue