From 8053d484f9fca3efd5ad78204d50f2b63988e42a Mon Sep 17 00:00:00 2001 From: Ettore Perazzoli Date: Fri, 6 Jul 2001 08:35:27 +0000 Subject: Added error dialogs for when the user tries to copy/move a folder over itself, or move it under one of its descendants. [Fixes #3959, copying a folder over itself crashes Evolution.] svn path=/trunk/; revision=10841 --- shell/ChangeLog | 9 +++++++++ shell/e-shell-folder-commands.c | 27 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) (limited to 'shell') diff --git a/shell/ChangeLog b/shell/ChangeLog index cdb77f31b4..ec728b43a1 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,12 @@ +2001-07-06 Ettore Perazzoli + + [Fix #3959, copying a folder over itself crashes Evolution.] + + * e-shell-folder-commands.c + (folder_selection_dialog_folder_selected_callback): Sanity checks: + don't allow copying a folder over itself, or moving it under one + of its descendants. In such cases, pop up an error dialog. + 2001-07-05 Iain Holmes * e-shortcuts-view.c (icon_callback): Special case the evolution:/My diff --git a/shell/e-shell-folder-commands.c b/shell/e-shell-folder-commands.c index d4670b7c29..e3276d609b 100644 --- a/shell/e-shell-folder-commands.c +++ b/shell/e-shell-folder-commands.c @@ -27,6 +27,8 @@ #include "e-shell-folder-commands.h" +#include + #include #include #include @@ -149,6 +151,31 @@ folder_selection_dialog_folder_selected_callback (EShellFolderSelectionDialog *f return; } + if (strcmp (folder_command_data->destination_path, + folder_command_data->source_path) == 0) { + const char *msg; + + if (remove_source) + msg = _("Cannot move a folder over itself."); + else + msg = _("Cannot copy a folder over itself."); + + e_notice (GTK_WINDOW (folder_selection_dialog), GNOME_MESSAGE_BOX_ERROR, msg); + return; + } + + if (remove_source) { + int source_len; + + source_len = strlen (folder_command_data->source_path); + if (strncmp (folder_command_data->destination_path, + folder_command_data->source_path, + source_len) == 0) { + e_notice (GTK_WINDOW (folder_selection_dialog), GNOME_MESSAGE_BOX_ERROR, + _("Cannot move a folder into one of its descendants.")); + } + } + storage_set = e_shell_get_storage_set (folder_command_data->shell); e_storage_set_async_xfer_folder (storage_set, -- cgit v1.2.3