Addl fix #741: Crash when creating new dir with same name as already existing file
authorColin Clark <cclark@carbon>
Sun, 2 Feb 2020 15:47:30 +0000 (15:47 +0000)
committerColin Clark <cclark@carbon>
Sun, 2 Feb 2020 15:47:30 +0000 (15:47 +0000)
https://github.com/BestImageViewer/geeqie/issues/741

Check for files as well as folders

src/utilops.c

index f1824c9..4f9d712 100644 (file)
@@ -787,21 +787,14 @@ static void file_util_perform_ci_dir(UtilityData *ud, gboolean internal, gboolea
                        GList *work;
                        g_assert(ud->dir_fd->sidecar_files == NULL); // directories should not have sidecars
 
-                       if (isdir(ud->dest_path))
+                       if ((internal && file_data_sc_perform_ci(ud->dir_fd)) ||
+                           (!internal && ext_result))
                                {
-                               fail = file_data_ref(ud->dir_fd);
+                               file_data_sc_apply_ci(ud->dir_fd);
                                }
                        else
                                {
-                               if ((internal && file_data_sc_perform_ci(ud->dir_fd)) ||
-                                   (!internal && ext_result))
-                                       {
-                                       file_data_sc_apply_ci(ud->dir_fd);
-                                       }
-                               else
-                                       {
-                                       fail = file_data_ref(ud->dir_fd);
-                                       }
+                               fail = file_data_ref(ud->dir_fd);
                                }
 
 
@@ -1019,6 +1012,17 @@ void file_util_check_ci(UtilityData *ud)
                        error = file_data_verify_ci_list(ud->flist, &desc, ud->with_sidecars);
                        }
                }
+       else
+               {
+               if (ud->type == UTILITY_TYPE_CREATE_FOLDER || ud->type == UTILITY_TYPE_RENAME_FOLDER)
+                       {
+                       if (isdir(ud->dest_path) || isfile(ud->dest_path))
+                               {
+                               error = CHANGE_DEST_EXISTS;
+                               desc = g_strdup_printf(_("%s already exists"), ud->dest_path);
+                               }
+                       }
+               }
 
        if (!error)
                {