Skip to content

Commit a7d9afd

Browse files
committed
add fsync to atomic_save for correctness
1 parent 6e0354e commit a7d9afd

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

boltons/fileutils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,9 @@ def __enter__(self):
465465

466466
def __exit__(self, exc_type, exc_val, exc_tb):
467467
if self.part_file:
468+
# Ensure data is flushed and synced to disk before closing
469+
self.part_file.flush()
470+
os.fsync(self.part_file.fileno())
468471
self.part_file.close()
469472
if exc_type:
470473
if self.rm_part_on_exc:

0 commit comments

Comments
 (0)