Fix #47 the state and config files are no longer invalidated when there
is no diskspace
This commit is contained in:
parent
1440d6b247
commit
4933618f50
|
@ -29,6 +29,7 @@ import cPickle
|
||||||
import os.path
|
import os.path
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import shutil
|
||||||
|
|
||||||
import gobject
|
import gobject
|
||||||
|
|
||||||
|
@ -531,12 +532,22 @@ 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"),
|
os.path.join(self.config["state_location"], "torrents.state.new"),
|
||||||
"wb")
|
"wb")
|
||||||
cPickle.dump(state, state_file)
|
cPickle.dump(state, state_file)
|
||||||
state_file.close()
|
state_file.close()
|
||||||
except IOError:
|
except IOError:
|
||||||
log.warning("Unable to save state file.")
|
log.warning("Unable to save state file.")
|
||||||
|
return True
|
||||||
|
|
||||||
|
# We have to move the 'torrents.state.new' file to 'torrents.state'
|
||||||
|
try:
|
||||||
|
shutil.move(
|
||||||
|
os.path.join(self.config["state_location"], "torrents.state.new"),
|
||||||
|
os.path.join(self.config["state_location"], "torrents.state"))
|
||||||
|
except IOError:
|
||||||
|
log.warning("Unable to save state file.")
|
||||||
|
return True
|
||||||
|
|
||||||
# We return True so that the timer thread will continue
|
# We return True so that the timer thread will continue
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in New Issue