From 0b4c53fc23581abb14b6d4c567dc08720f509020 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 8 Jun 2019 18:12:28 -0400 Subject: 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. https://github.com/vim/vim/commit/7567d0b115e332f61a9f390aaccdf7825b891227 --- src/nvim/fileio.c | 2 +- src/nvim/globals.h | 1 + src/nvim/testdir/test_writefile.vim | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index e2b77d9605..f2a664288b 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -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; } diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 78409267a4..40184a4bb9 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -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")); diff --git a/src/nvim/testdir/test_writefile.vim b/src/nvim/testdir/test_writefile.vim index 9c9e051bc9..9da9df2150 100644 --- a/src/nvim/testdir/test_writefile.vim +++ b/src/nvim/testdir/test_writefile.vim @@ -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 -- cgit