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:
Andrew Resch 2009-03-08 20:27:58 +00:00
parent 8f4583bc23
commit 3cab036b70

View File

@ -541,6 +541,8 @@ class TorrentManager(component.Component):
os.path.join(self.config["state_location"], "torrents.state.new"),
"wb")
cPickle.dump(state, state_file)
state_file.flush()
os.fsync(state_file.fileno())
state_file.close()
except IOError:
log.warning("Unable to save state file.")