Skip to content

Conversation

@jmckaskill
Copy link

Standard process for an atomic update on unix systems is:

  1. Write new contents to a temp file on same filesystem/folder
  2. fsync the file
  3. Close the file
  4. Rename the temp file over top of the existing file

The existing code was missing #2. If you lose power soon after persisting a new file, the file rename can be synced through without the new data contents. If that happens you end up losing your settings.

Standard process for an atomic update on unix systems is:
1. Write new contents to a temp file on same filesystem/folder
2. fsync the file
3. Close the file
4. Rename the temp file over top of the existing file

The existing code was missing seladb#2. If you lose power soon after
persisting a new file, the file rename can be synced through without the
new data contents. If that happens you end up losing your settings.
@seladb
Copy link
Owner

seladb commented Jul 19, 2024

@jmckaskill I'm not sure I understand. Why do we need fsync here? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants