diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-05-24 19:18:11 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-05-24 19:18:11 +0000 |
commit | ff7ed8f586589d620a806c3758fac4a47a8e7e15 (patch) | |
tree | 729bbcb92231538fa61dab6c3d890b025484b7f5 /src/nvim/bufwrite.c | |
parent | 376914f419eb08fdf4c1a63a77e1f035898a0f10 (diff) | |
parent | 28c04948a1c887a1cc0cb64de79fa32631700466 (diff) | |
download | rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.gz rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.bz2 rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.zip |
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'src/nvim/bufwrite.c')
-rw-r--r-- | src/nvim/bufwrite.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index 94a6604fc1..27de03954a 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -900,38 +900,31 @@ static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_o // remove old backup, if present os_remove(*backupp); + // copy the file + if (os_copy(fname, *backupp, UV_FS_COPYFILE_FICLONE) != 0) { + *err = set_err(_("E509: Cannot create backup file (add ! to override)")); + XFREE_CLEAR(*backupp); + *backupp = NULL; + continue; + } + // set file protection same as original file, but // strip s-bit. os_setperm(*backupp, perm & 0777); #ifdef UNIX - // // Try to set the group of the backup same as the original file. If // this fails, set the protection bits for the group same as the // protection bits for others. - // if (file_info_new.stat.st_gid != file_info_old->stat.st_gid && os_chown(*backupp, (uv_uid_t)-1, (uv_gid_t)file_info_old->stat.st_gid) != 0) { os_setperm(*backupp, (perm & 0707) | ((perm & 07) << 3)); } -# ifdef HAVE_XATTR - os_copy_xattr(fname, *backupp); -# endif -#endif - - // copy the file - if (os_copy(fname, *backupp, UV_FS_COPYFILE_FICLONE) != 0) { - *err = set_err(_("E509: Cannot create backup file (add ! to override)")); - XFREE_CLEAR(*backupp); - *backupp = NULL; - continue; - } - -#ifdef UNIX os_file_settime(*backupp, (double)file_info_old->stat.st_atim.tv_sec, (double)file_info_old->stat.st_mtim.tv_sec); #endif + os_set_acl(*backupp, acl); #ifdef HAVE_XATTR os_copy_xattr(fname, *backupp); |