From a78abf2f994952bea5dd6ca887ca3ca10158c072 Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <ossi@kde.org>
Date: Sun, 15 Dec 2013 18:49:14 +0100
Subject: [PATCH 01/11] fix file out-of-date-ness check on saving
the code depended on the execution and outcome of the hardlink check.
this was bogus - the two checks have nothing in common except the stat()
call they both depend on.
---
src/editor/editcmd.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/editor/editcmd.c b/src/editor/editcmd.c
index b726b85..80a1565 100644
a
|
b
|
edit_save_file (WEdit * edit, const vfs_path_t * filename_vpath) |
156 | 156 | char *p; |
157 | 157 | gchar *tmp; |
158 | 158 | off_t filelen = 0; |
159 | | int this_save_mode, fd = -1; |
| 159 | int this_save_mode, rv, fd = -1; |
160 | 160 | vfs_path_t *real_filename_vpath; |
161 | 161 | vfs_path_t *savename_vpath = NULL; |
162 | 162 | const char *start_filename; |
163 | 163 | const vfs_path_element_t *vpath_element; |
| 164 | struct stat sb; |
164 | 165 | |
165 | 166 | vpath_element = vfs_path_get_by_index (filename_vpath, 0); |
166 | 167 | if (vpath_element == NULL) |
… |
… |
edit_save_file (WEdit * edit, const vfs_path_t * filename_vpath) |
195 | 196 | mc_close (fd); |
196 | 197 | } |
197 | 198 | |
198 | | if (this_save_mode == EDIT_QUICK_SAVE && !edit->skip_detach_prompt) |
| 199 | rv = mc_stat (real_filename_vpath, &sb); |
| 200 | if (rv == 0) |
199 | 201 | { |
200 | | int rv; |
201 | | struct stat sb; |
202 | | |
203 | | rv = mc_stat (real_filename_vpath, &sb); |
204 | | if (rv == 0 && sb.st_nlink > 1) |
| 202 | if (this_save_mode == EDIT_QUICK_SAVE && !edit->skip_detach_prompt && sb.st_nlink > 1) |
205 | 203 | { |
206 | 204 | rv = edit_query_dialog3 (_("Warning"), |
207 | 205 | _("File has hard-links. Detach before saving?"), |
… |
… |
edit_save_file (WEdit * edit, const vfs_path_t * filename_vpath) |
221 | 219 | } |
222 | 220 | |
223 | 221 | /* Prevent overwriting changes from other editor sessions. */ |
224 | | if (rv == 0 && edit->stat1.st_mtime != 0 && edit->stat1.st_mtime != sb.st_mtime) |
| 222 | if (edit->stat1.st_mtime != 0 && edit->stat1.st_mtime != sb.st_mtime) |
225 | 223 | { |
226 | 224 | /* The default action is "Cancel". */ |
227 | 225 | query_set_sel (1); |