mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-18 17:29:28 +03:00
Merge branch '3142_edit_save_check_out_of_date'
* 3142_edit_save_check_out_of_date: Ticket #3142: fix file out-of-date-ness check on saving.
This commit is contained in:
commit
c4188ee235
@ -159,11 +159,12 @@ edit_save_file (WEdit * edit, const vfs_path_t * filename_vpath)
|
|||||||
char *p;
|
char *p;
|
||||||
gchar *tmp;
|
gchar *tmp;
|
||||||
off_t filelen = 0;
|
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 *real_filename_vpath;
|
||||||
vfs_path_t *savename_vpath = NULL;
|
vfs_path_t *savename_vpath = NULL;
|
||||||
const char *start_filename;
|
const char *start_filename;
|
||||||
const vfs_path_element_t *vpath_element;
|
const vfs_path_element_t *vpath_element;
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
vpath_element = vfs_path_get_by_index (filename_vpath, 0);
|
vpath_element = vfs_path_get_by_index (filename_vpath, 0);
|
||||||
if (vpath_element == NULL)
|
if (vpath_element == NULL)
|
||||||
@ -198,13 +199,10 @@ edit_save_file (WEdit * edit, const vfs_path_t * filename_vpath)
|
|||||||
mc_close (fd);
|
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;
|
if (this_save_mode == EDIT_QUICK_SAVE && !edit->skip_detach_prompt && sb.st_nlink > 1)
|
||||||
struct stat sb;
|
|
||||||
|
|
||||||
rv = mc_stat (real_filename_vpath, &sb);
|
|
||||||
if (rv == 0 && sb.st_nlink > 1)
|
|
||||||
{
|
{
|
||||||
rv = edit_query_dialog3 (_("Warning"),
|
rv = edit_query_dialog3 (_("Warning"),
|
||||||
_("File has hard-links. Detach before saving?"),
|
_("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. */
|
/* 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". */
|
/* The default action is "Cancel". */
|
||||||
query_set_sel (1);
|
query_set_sel (1);
|
||||||
|
Loading…
Reference in New Issue
Block a user