[Jonathan Michalon] flush and fsync config file before closing it. Fixes #5768
This commit is contained in:
parent
b86bff4d5f
commit
28e3c36944
1 changed files with 8 additions and 5 deletions
|
@ -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:
|
||||||
|
|
Loading…
Add table
Reference in a new issue