diff --git a/nvchecker/core.py b/nvchecker/core.py index a3af337..d369231 100644 --- a/nvchecker/core.py +++ b/nvchecker/core.py @@ -41,6 +41,9 @@ def safe_overwrite(fname, data, *, method='write', mode='w', encoding=None): # if not using "with", write can fail without exception with open(tmpname, mode, encoding=encoding) as f: getattr(f, method)(data) + # see also: https://thunk.org/tytso/blog/2009/03/15/dont-fear-the-fsync/ + f.flush() + os.fsync(f.fileno()) # if the above write failed (because disk is full etc), the old data should be kept os.rename(tmpname, fname)