mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 10:04:32 +03:00
Ticket #3142: 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.
This commit is contained in:
parent
62e1606106
commit
58bba43490
@ -159,11 +159,12 @@ edit_save_file (WEdit * edit, const vfs_path_t * filename_vpath)
|
||||
char *p;
|
||||
gchar *tmp;
|
||||
off_t filelen = 0;
|
||||
int this_save_mode, fd = -1;
|
||||
int this_save_mode, rv, fd = -1;
|
||||
vfs_path_t *real_filename_vpath;
|
||||
vfs_path_t *savename_vpath = NULL;
|
||||
const char *start_filename;
|
||||
const vfs_path_element_t *vpath_element;
|
||||
struct stat sb;
|
||||
|
||||
vpath_element = vfs_path_get_by_index (filename_vpath, 0);
|
||||
if (vpath_element == NULL)
|
||||
@ -198,13 +199,10 @@ edit_save_file (WEdit * edit, const vfs_path_t * filename_vpath)
|
||||
mc_close (fd);
|
||||
}
|
||||
|
||||
if (this_save_mode == EDIT_QUICK_SAVE && !edit->skip_detach_prompt)
|
||||
rv = mc_stat (real_filename_vpath, &sb);
|
||||
if (rv == 0)
|
||||
{
|
||||
int rv;
|
||||
struct stat sb;
|
||||
|
||||
rv = mc_stat (real_filename_vpath, &sb);
|
||||
if (rv == 0 && sb.st_nlink > 1)
|
||||
if (this_save_mode == EDIT_QUICK_SAVE && !edit->skip_detach_prompt && sb.st_nlink > 1)
|
||||
{
|
||||
rv = edit_query_dialog3 (_("Warning"),
|
||||
_("File has hard-links. Detach before saving?"),
|
||||
@ -224,7 +222,7 @@ edit_save_file (WEdit * edit, const vfs_path_t * filename_vpath)
|
||||
}
|
||||
|
||||
/* Prevent overwriting changes from other editor sessions. */
|
||||
if (rv == 0 && edit->stat1.st_mtime != 0 && edit->stat1.st_mtime != sb.st_mtime)
|
||||
if (edit->stat1.st_mtime != 0 && edit->stat1.st_mtime != sb.st_mtime)
|
||||
{
|
||||
/* The default action is "Cancel". */
|
||||
query_set_sel (1);
|
||||
|
Loading…
Reference in New Issue
Block a user