1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-25 01:06:50 +00:00

do os.fsync like recommended in the python docs (gets a fileno, not file object, also do a flush first)

This commit is contained in:
Thomas Waldmann 2015-02-28 02:45:21 +01:00
parent 0e5ef376bf
commit 74768511e1
2 changed files with 3 additions and 2 deletions

View file

@ -481,7 +481,7 @@ def write_msgpack(filename, d):
with open(filename + '.tmp', 'wb') as fd:
msgpack.pack(d, fd)
fd.flush()
os.fsync(fd)
os.fsync(fd.fileno())
os.rename(filename + '.tmp', filename)

View file

@ -577,6 +577,7 @@ def close_segment(self):
if self._write_fd:
self.segment += 1
self.offset = 0
os.fsync(self._write_fd)
self._write_fd.flush()
os.fsync(self._write_fd.fileno())
self._write_fd.close()
self._write_fd = None