mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-08 09:28:41 +00:00
Make sure config files, resume data and state are fsync'd when saved. This should help prevent data
losses on crashes/improper shutdowns.
This commit is contained in:
parent
fdf78bc7fd
commit
c2de5ed93f
4 changed files with 19 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
||||||
* Fix displaying file errors when the torrent isn't paused
|
* Fix displaying file errors when the torrent isn't paused
|
||||||
* Fix issue where torrents being check would get removed due to "stop at ratio" rules
|
* Fix issue where torrents being check would get removed due to "stop at ratio" rules
|
||||||
* Fix #790 tracker hosts not correct for some .uk trackers
|
* Fix #790 tracker hosts not correct for some .uk trackers
|
||||||
|
* Make sure config files, resume data and state are fsync'd when saved. This should help prevent data losses on crashes/improper shutdowns.
|
||||||
|
|
||||||
==== GtkUI ====
|
==== GtkUI ====
|
||||||
* Fix hiding bottom pane when no tabs are enabled upon restart
|
* Fix hiding bottom pane when no tabs are enabled upon restart
|
||||||
|
|
|
@ -264,13 +264,26 @@ class Config(object):
|
||||||
|
|
||||||
self.__save_timer = None
|
self.__save_timer = None
|
||||||
|
|
||||||
|
# Save the new config and make sure it's written to disk
|
||||||
try:
|
try:
|
||||||
log.debug("Saving new config file %s", filename + ".new")
|
log.debug("Saving new config file %s", filename + ".new")
|
||||||
pickle.dump(self.__config, open(filename + ".new", "wb"))
|
f = open(filename + ".new", "w")
|
||||||
|
pickle.dump(self.__config, f)
|
||||||
|
f.flush()
|
||||||
|
os.fsync(f.fileno())
|
||||||
|
f.close()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error("Error writing new config file: %s", e)
|
log.error("Error writing new config file: %s", e)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Make a backup of the old config
|
||||||
|
try:
|
||||||
|
log.debug("Backing up old config file to %s~", filename)
|
||||||
|
shutil.move(filename, filename + "~")
|
||||||
|
except Exception, e:
|
||||||
|
log.error("Error backing up old config..")
|
||||||
|
return
|
||||||
|
|
||||||
# The new config file has been written successfully, so let's move it over
|
# The new config file has been written successfully, so let's move it over
|
||||||
# the existing one.
|
# the existing one.
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -762,6 +762,8 @@ class Torrent:
|
||||||
log.debug("Saving fastresume file: %s", path)
|
log.debug("Saving fastresume file: %s", path)
|
||||||
fastresume = open(path, "wb")
|
fastresume = open(path, "wb")
|
||||||
fastresume.write(resume_data)
|
fastresume.write(resume_data)
|
||||||
|
fastresume.flush()
|
||||||
|
os.fsync(fastresume.fileno())
|
||||||
fastresume.close()
|
fastresume.close()
|
||||||
except IOError:
|
except IOError:
|
||||||
log.warning("Error trying to save fastresume file")
|
log.warning("Error trying to save fastresume file")
|
||||||
|
|
|
@ -540,6 +540,8 @@ class TorrentManager(component.Component):
|
||||||
os.path.join(self.config["state_location"], "torrents.state.new"),
|
os.path.join(self.config["state_location"], "torrents.state.new"),
|
||||||
"wb")
|
"wb")
|
||||||
cPickle.dump(state, state_file)
|
cPickle.dump(state, state_file)
|
||||||
|
state_file.flush()
|
||||||
|
os.fsync(state_file.fileno())
|
||||||
state_file.close()
|
state_file.close()
|
||||||
except IOError:
|
except IOError:
|
||||||
log.warning("Unable to save state file.")
|
log.warning("Unable to save state file.")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue