1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-30 11:11:28 +00:00

make sure data hits disk before commit tag, fixes #1236

This commit is contained in:
Thomas Waldmann 2016-07-01 01:11:12 +02:00
parent 02c72b9925
commit fde5a60549

View file

@ -727,8 +727,11 @@ def write_commit(self):
fd = self.get_write_fd(no_new=True)
header = self.header_no_crc_fmt.pack(self.header_fmt.size, TAG_COMMIT)
crc = self.crc_fmt.pack(crc32(header) & 0xffffffff)
# first fsync(fd) here (to ensure data supposedly hits the disk before the commit tag)
fd.flush()
os.fsync(fd.fileno())
fd.write(b''.join((crc, header)))
self.close_segment()
self.close_segment() # after-commit fsync()
def close_segment(self):
if self._write_fd: