From 44ca3574b1f95d8217ca272c254b054914bdf247 Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Sun, 2 Feb 2020 15:47:30 +0000 Subject: [PATCH] Addl fix #741: Crash when creating new dir with same name as already existing file https://github.com/BestImageViewer/geeqie/issues/741 Check for files as well as folders --- src/utilops.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/utilops.c b/src/utilops.c index f1824c9c..4f9d7126 100644 --- a/src/utilops.c +++ b/src/utilops.c @@ -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) { -- 2.20.1