vim-patch:8.0.1305: writefile() never calls fsync() #10153

Problem:    Writefile() never calls fsync().
Solution:   Follow the 'fsync' option with override to enable or disable.
7567d0b115
This commit is contained in:
Jan Edmund Lazo
2019-06-08 18:12:28 -04:00
committed by Justin M. Keyes
parent 93afb34712
commit 0b4c53fc23
4 changed files with 10 additions and 2 deletions

View File

@@ -8958,7 +8958,7 @@ winwidth({nr}) *winwidth()*
Examples: >
:echo "The current window has " . winwidth(0) . " columns."
:if winwidth(0) <= 50
: exe "normal 50\<C-W>|"
: 50 wincmd |
:endif
< For getting the terminal or screen size, see the 'columns'
option.

View File

@@ -3363,7 +3363,7 @@ restore_backup:
if (p_fs && (error = os_fsync(fd)) != 0 && !device
// fsync not supported on this storage.
&& error != UV_ENOTSUP) {
SET_ERRMSG_ARG(_("E667: Fsync failed: %s"), error);
SET_ERRMSG_ARG(e_fsync, error);
end = 0;
}

View File

@@ -958,6 +958,7 @@ EXTERN char_u e_streamkey[] INIT(= N_(
"E5210: dict key '%s' already set for buffered stream in channel %"
PRIu64));
EXTERN char_u e_libcall[] INIT(= N_("E364: Library call failed for \"%s()\""));
EXTERN char e_fsync[] INIT(= N_("E667: Fsync failed: %s"));
EXTERN char_u e_mkdir[] INIT(= N_("E739: Cannot create directory %s: %s"));
EXTERN char_u e_markinval[] INIT(= N_("E19: Mark has invalid line number"));
EXTERN char_u e_marknotset[] INIT(= N_("E20: Mark not set"));

View File

@@ -167,3 +167,10 @@ func Test_writefile_sync_dev_stdout()
throw 'Skipped: /dev/stdout is not writable'
endif
endfunc
func Test_writefile_sync_arg()
" This doesn't check if fsync() works, only that the argument is accepted.
call writefile(['one'], 'Xtest', 's')
call writefile(['two'], 'Xtest', 'S')
call delete('Xtest')
endfunc