Skip to content

Commit

Permalink
add fsync to atomic_save for correctness
Browse files Browse the repository at this point in the history
  • Loading branch information
mahmoud committed Feb 3, 2025
1 parent 6e0354e commit a7d9afd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions boltons/fileutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,9 @@ def __enter__(self):

def __exit__(self, exc_type, exc_val, exc_tb):
if self.part_file:
# Ensure data is flushed and synced to disk before closing
self.part_file.flush()
os.fsync(self.part_file.fileno())
self.part_file.close()
if exc_type:
if self.rm_part_on_exc:
Expand Down

0 comments on commit a7d9afd

Please sign in to comment.