From 5b45efbee6ebb64269469b636baac5248e83421f Mon Sep 17 00:00:00 2001 From: Ploum <1233155+ploum@users.noreply.github.com> Date: Tue, 14 Nov 2023 11:56:50 +0100 Subject: fix(defaults): set 'fsync' #26034 Problem: 'nofsync' may lose data if the system has a hard shutdown. #9888 Solution: Change default to 'fsync'. This may be revisited in the future when 'nofsync' can be made safer. --- runtime/doc/options.txt | 2 +- runtime/doc/vim_diff.txt | 1 - src/nvim/options.lua | 2 +- test/functional/core/fileio_spec.lua | 1 + 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 7f2eb9da07..603b777f55 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -2796,7 +2796,7 @@ A jump table for the options with a short description can be found at |Q_op|. security reasons. *'fsync'* *'fs'* *'nofsync'* *'nofs'* -'fsync' 'fs' boolean (default off) +'fsync' 'fs' boolean (default on) global When on, the OS function fsync() will be called after saving a file (|:write|, |writefile()|, …), |swap-file|, |undo-persistence| and |shada-file|. diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 1e12ccd7cc..05d7e5feb9 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -47,7 +47,6 @@ Defaults *nvim-defaults* - 'encoding' is UTF-8 (cf. 'fileencoding' for file-content encoding) - 'fillchars' defaults (in effect) to "vert:│,fold:·,foldsep:│" - 'formatoptions' defaults to "tcqj" -- 'fsync' is disabled - 'hidden' is enabled - 'history' defaults to 10000 (the maximum) - 'hlsearch' is enabled diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 56ecf26fdf..373dc3c460 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -3307,7 +3307,7 @@ return { }, { abbreviation = 'fs', - defaults = { if_true = false }, + defaults = { if_true = true }, desc = [=[ When on, the OS function fsync() will be called after saving a file (|:write|, |writefile()|, …), |swap-file|, |undo-persistence| and |shada-file|. diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua index a23dad226a..65f947132e 100644 --- a/test/functional/core/fileio_spec.lua +++ b/test/functional/core/fileio_spec.lua @@ -51,6 +51,7 @@ describe('fileio', function() it('fsync() codepaths #8304', function() clear({ args={ '-i', 'Xtest_startup_shada', + '--cmd', 'set nofsync', '--cmd', 'set directory=Xtest_startup_swapdir' } }) -- These cases ALWAYS force fsync (regardless of 'fsync' option): -- cgit