Skip to content

gfileutils: document non-atomicity of g_file_set_contents()

Will Thompson requested to merge non-atomicity-of-g_file_set_contents into master

This function only calls fsync() if @target exists and is non-empty. If not, it doesn't provide the "old contents or new contents" guarantee that one might expect. This has been the case since d20a188b, and is justified either as a performance optimization or by asserting that this function only guarantees to not destroy existing data (implicitly defining non-existence or emptiness as not data).

In addition, explicitly spell out that whether it's atomic in the non-empty case is system-dependent. If the system administrator has configured some funky filesystem options, they may be out of luck on the atomicity front.

This wording is a combination of my own and @walters' on #1302 (closed).

Merge request reports