Hacker News new | ask | show | jobs
by jeffffff 66 days ago
don't forget to fsync the file before the rename! and you also need to fsync the directory after the rename!
1 comments

Correct, the file must be flushed to disk! I'm so used to libraries handling it that I forgot to mention that.

I believe syncing the parent directory is only needed for durability and not atomicity, but if you're using this method you're probably not caring about durability in the first place, because you've designed a system that doesn't let you do durability in a fine-grained way without severe performance loss.