Ticket #3142: 0001-fix-file-out-of-date-ness-check-on-saving.patch

File 0001-fix-file-out-of-date-ness-check-on-saving.patch, 2.2 KB (added by ossi, 9 years ago)
  • src/editor/editcmd.c

    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) 
    156156    char *p; 
    157157    gchar *tmp; 
    158158    off_t filelen = 0; 
    159     int this_save_mode, fd = -1; 
     159    int this_save_mode, rv, fd = -1; 
    160160    vfs_path_t *real_filename_vpath; 
    161161    vfs_path_t *savename_vpath = NULL; 
    162162    const char *start_filename; 
    163163    const vfs_path_element_t *vpath_element; 
     164    struct stat sb; 
    164165 
    165166    vpath_element = vfs_path_get_by_index (filename_vpath, 0); 
    166167    if (vpath_element == NULL) 
    edit_save_file (WEdit * edit, const vfs_path_t * filename_vpath) 
    195196            mc_close (fd); 
    196197    } 
    197198 
    198     if (this_save_mode == EDIT_QUICK_SAVE && !edit->skip_detach_prompt) 
     199    rv = mc_stat (real_filename_vpath, &sb); 
     200    if (rv == 0) 
    199201    { 
    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) 
    205203        { 
    206204            rv = edit_query_dialog3 (_("Warning"), 
    207205                                     _("File has hard-links. Detach before saving?"), 
    edit_save_file (WEdit * edit, const vfs_path_t * filename_vpath) 
    221219        } 
    222220 
    223221        /* 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) 
    225223        { 
    226224            /* The default action is "Cancel". */ 
    227225            query_set_sel (1);