[Jonathan Michalon] flush and fsync config file before closing it. Fixes #5768

This commit is contained in:
Yann Leboulanger 2010-06-02 22:14:57 +02:00
parent b86bff4d5f
commit 28e3c36944

View file

@ -115,13 +115,16 @@ class OptionsParser:
gajim.config.foreach(self.write_line, f) gajim.config.foreach(self.write_line, f)
except IOError, e: except IOError, e:
return str(e) return str(e)
f.flush()
os.fsync(f.fileno())
f.close() f.close()
if os.path.exists(self.__filename): if os.path.exists(self.__filename):
# win32 needs this if os.name == 'nt':
try: # win32 needs this
os.remove(self.__filename) try:
except Exception: os.remove(self.__filename)
pass except Exception:
pass
try: try:
os.rename(self.__tempfile, self.__filename) os.rename(self.__tempfile, self.__filename)
except IOError, e: except IOError, e: