fix(defaults): set 'fsync' #26039

backport #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.

Co-authored-by: Ploum <1233155+ploum@users.noreply.github.com>
This commit is contained in:
Justin M. Keyes
2023-11-14 03:34:59 -08:00
committed by GitHub
parent 7ce36b7997
commit 2a467acc86
4 changed files with 3 additions and 3 deletions

View File

@@ -2765,7 +2765,7 @@ A jump table for the options with a short description can be found at |Q_op|.
security reasons. security reasons.
*'fsync'* *'fs'* *'nofsync'* *'nofs'* *'fsync'* *'fs'* *'nofsync'* *'nofs'*
'fsync' 'fs' boolean (default off) 'fsync' 'fs' boolean (default on)
global global
When on, the OS function fsync() will be called after saving a file When on, the OS function fsync() will be called after saving a file
(|:write|, |writefile()|, …), |swap-file|, |undo-persistence| and |shada-file|. (|:write|, |writefile()|, …), |swap-file|, |undo-persistence| and |shada-file|.

View File

@@ -42,7 +42,6 @@ Defaults *nvim-defaults*
- 'encoding' is UTF-8 (cf. 'fileencoding' for file-content encoding) - 'encoding' is UTF-8 (cf. 'fileencoding' for file-content encoding)
- 'fillchars' defaults (in effect) to "vert:│,fold:·,sep:│" - 'fillchars' defaults (in effect) to "vert:│,fold:·,sep:│"
- 'formatoptions' defaults to "tcqj" - 'formatoptions' defaults to "tcqj"
- 'fsync' is disabled
- 'hidden' is enabled - 'hidden' is enabled
- 'history' defaults to 10000 (the maximum) - 'history' defaults to 10000 (the maximum)
- 'hlsearch' is enabled - 'hlsearch' is enabled

View File

@@ -942,7 +942,7 @@ return {
type='bool', scope={'global'}, type='bool', scope={'global'},
secure=true, secure=true,
varname='p_fs', varname='p_fs',
defaults={if_true=false} defaults={if_true=true}
}, },
{ {
full_name='gdefault', abbreviation='gd', full_name='gdefault', abbreviation='gd',

View File

@@ -50,6 +50,7 @@ describe('fileio', function()
it('fsync() codepaths #8304', function() it('fsync() codepaths #8304', function()
clear({ args={ '-i', 'Xtest_startup_shada', clear({ args={ '-i', 'Xtest_startup_shada',
'--cmd', 'set nofsync',
'--cmd', 'set directory=Xtest_startup_swapdir' } }) '--cmd', 'set directory=Xtest_startup_swapdir' } })
-- These cases ALWAYS force fsync (regardless of 'fsync' option): -- These cases ALWAYS force fsync (regardless of 'fsync' option):