[gnome-commander] Respect the users choice what to do if a file which should be copied already exists
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Respect the users choice what to do if a file which should be copied already exists
- Date: Tue, 14 Sep 2021 20:09:41 +0000 (UTC)
commit 290066f791b485d7bbb10de109d428e6d6db0c47
Author: Uwe Scholz <u scholz83 gmx de>
Date: Tue Sep 14 21:02:51 2021 +0200
Respect the users choice what to do if a file which should be copied already exists
Taking care about the move operation via GIO
src/dialogs/gnome-cmd-options-dialog.cc | 21 ++-
src/dialogs/gnome-cmd-prepare-copy-dialog.cc | 12 +-
src/dialogs/gnome-cmd-prepare-move-dialog.cc | 39 +++--
src/dialogs/gnome-cmd-prepare-xfer-dialog.cc | 39 +++--
src/dialogs/gnome-cmd-prepare-xfer-dialog.h | 2 +-
src/gnome-cmd-types.h | 8 +
src/gnome-cmd-xfer.cc | 247 ++++++++++++++++-----------
src/gnome-cmd-xfer.h | 9 +-
8 files changed, 227 insertions(+), 150 deletions(-)
---
diff --git a/src/dialogs/gnome-cmd-options-dialog.cc b/src/dialogs/gnome-cmd-options-dialog.cc
index 9f9ab1af..726f8a08 100644
--- a/src/dialogs/gnome-cmd-options-dialog.cc
+++ b/src/dialogs/gnome-cmd-options-dialog.cc
@@ -1081,21 +1081,25 @@ static GtkWidget *create_confirmation_tab (GtkWidget *parent, GnomeCmdData::Opti
/* Move overwrite options
*/
cat_box = create_vbox (parent, FALSE, 0);
- cat = create_category (parent, cat_box, _("Move overwrite"));
+ cat = create_category (parent, cat_box, _("Preselected overwrite action in move dialog"));
gtk_box_pack_start (GTK_BOX (vbox), cat, FALSE, TRUE, 0);
- radio = create_radio (parent, NULL, _("Overwrite silently"), "move_overwrite_silently");
- gtk_box_pack_start (GTK_BOX (cat_box), radio, FALSE, TRUE, 0);
- if (cfg.confirm_move_overwrite==GNOME_CMD_CONFIRM_OVERWRITE_SILENTLY)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
- radio = create_radio (parent, get_radio_group (radio), _("Query first"), "move_overwrite_query");
+ radio = create_radio (parent, NULL, _("Query first"), "move_overwrite_query");
gtk_container_add (GTK_CONTAINER (cat_box), radio);
if (cfg.confirm_move_overwrite==GNOME_CMD_CONFIRM_OVERWRITE_QUERY)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
- radio = create_radio (parent, get_radio_group (radio), _("Skip all"), "move_overwrite_skip_all");
+ radio = create_radio (parent, get_radio_group (radio), _("Rename"), "move_rename_all");
+ gtk_container_add (GTK_CONTAINER (cat_box), radio);
+ if (cfg.confirm_move_overwrite==GNOME_CMD_CONFIRM_OVERWRITE_RENAME_ALL)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
+ radio = create_radio (parent, get_radio_group (radio), _("Skip"), "move_overwrite_skip_all");
gtk_container_add (GTK_CONTAINER (cat_box), radio);
if (cfg.confirm_move_overwrite==GNOME_CMD_CONFIRM_OVERWRITE_SKIP_ALL)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
+ radio = create_radio (parent, get_radio_group (radio), _("Overwrite silently"),
"move_overwrite_silently");
+ gtk_box_pack_start (GTK_BOX (cat_box), radio, FALSE, TRUE, 0);
+ if (cfg.confirm_move_overwrite==GNOME_CMD_CONFIRM_OVERWRITE_SILENTLY)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
/* Drag and Drop options
@@ -1123,6 +1127,7 @@ void store_confirmation_options (GtkWidget *dialog, GnomeCmdData::Options &cfg)
GtkWidget *confirm_copy_skip_all = lookup_widget (dialog, "copy_overwrite_skip_all");
GtkWidget *confirm_move_silent = lookup_widget (dialog, "move_overwrite_silently");
GtkWidget *confirm_move_query = lookup_widget (dialog, "move_overwrite_query");
+ GtkWidget *confirm_move_rename_all = lookup_widget (dialog, "move_rename_all");
GtkWidget *confirm_move_skip_all = lookup_widget (dialog, "move_overwrite_skip_all");
GtkWidget *confirm_mouse_dnd_check = lookup_widget (dialog, "confirm_mouse_dnd_check");
@@ -1143,6 +1148,8 @@ void store_confirmation_options (GtkWidget *dialog, GnomeCmdData::Options &cfg)
cfg.confirm_move_overwrite = GNOME_CMD_CONFIRM_OVERWRITE_SILENTLY;
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (confirm_move_query)))
cfg.confirm_move_overwrite = GNOME_CMD_CONFIRM_OVERWRITE_QUERY;
+ else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (confirm_move_rename_all)))
+ cfg.confirm_move_overwrite = GNOME_CMD_CONFIRM_OVERWRITE_RENAME_ALL;
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (confirm_move_skip_all)))
cfg.confirm_move_overwrite = GNOME_CMD_CONFIRM_OVERWRITE_SKIP_ALL;
diff --git a/src/dialogs/gnome-cmd-prepare-copy-dialog.cc b/src/dialogs/gnome-cmd-prepare-copy-dialog.cc
index 89bb9fa2..f2fdb9b9 100644
--- a/src/dialogs/gnome-cmd-prepare-copy-dialog.cc
+++ b/src/dialogs/gnome-cmd-prepare-copy-dialog.cc
@@ -51,8 +51,9 @@ static void on_ok (GtkButton *button, gpointer user_data)
{
PrepareCopyData *data = (PrepareCopyData *) user_data;
GnomeCmdPrepareXferDialog *dlg = data->dialog;
+ dlg->gnomeCmdTransferType = COPY;
- guint gFileCopyFlags = 0;
+ guint gFileCopyFlags = G_FILE_COPY_NONE;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->silent)))
{
@@ -68,17 +69,10 @@ static void on_ok (GtkButton *button, gpointer user_data)
else
dlg->overwriteMode = GNOME_CMD_CONFIRM_OVERWRITE_SKIP_ALL;
- guint xferOptions = GNOME_VFS_XFER_RECURSIVE;
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->follow_links)))
- {
- xferOptions |= GNOME_VFS_XFER_FOLLOW_LINKS;
- }
- else
+ if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->follow_links)))
{
gFileCopyFlags |= G_FILE_COPY_NOFOLLOW_SYMLINKS;
}
- dlg->xferOptions = (GnomeVFSXferOptions) xferOptions;
dlg->gFileCopyFlags = (GFileCopyFlags) gFileCopyFlags;
}
diff --git a/src/dialogs/gnome-cmd-prepare-move-dialog.cc b/src/dialogs/gnome-cmd-prepare-move-dialog.cc
index bce059de..643a847f 100644
--- a/src/dialogs/gnome-cmd-prepare-move-dialog.cc
+++ b/src/dialogs/gnome-cmd-prepare-move-dialog.cc
@@ -39,6 +39,7 @@ typedef struct
GnomeCmdPrepareXferDialog *dialog;
GtkWidget *silent;
GtkWidget *query;
+ GtkWidget *rename;
GtkWidget *skip;
} PrepareMoveData;
@@ -48,16 +49,25 @@ static void on_ok (GtkButton *button, gpointer user_data)
{
PrepareMoveData *data = (PrepareMoveData *) user_data;
GnomeCmdPrepareXferDialog *dlg = data->dialog;
+ dlg->gnomeCmdTransferType = MOVE;
+
+ guint gFileCopyFlags = G_FILE_COPY_NONE;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->silent)))
+ {
dlg->overwriteMode = GNOME_CMD_CONFIRM_OVERWRITE_SILENTLY;
+ gFileCopyFlags |= G_FILE_COPY_OVERWRITE;
+ }
else
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->query)))
dlg->overwriteMode = GNOME_CMD_CONFIRM_OVERWRITE_QUERY;
else
- dlg->overwriteMode = GNOME_CMD_CONFIRM_OVERWRITE_SKIP_ALL;
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->rename)))
+ dlg->overwriteMode = GNOME_CMD_CONFIRM_OVERWRITE_RENAME_ALL;
+ else
+ dlg->overwriteMode = GNOME_CMD_CONFIRM_OVERWRITE_SKIP_ALL;
- dlg->xferOptions = GNOME_VFS_XFER_REMOVESOURCE;
+ dlg->gFileCopyFlags = (GFileCopyFlags) gFileCopyFlags;
}
@@ -79,14 +89,7 @@ void gnome_cmd_prepare_move_dialog_show (GnomeCmdFileSelector *from, GnomeCmdFil
gtk_widget_ref (GTK_WIDGET (data->dialog));
- // Create prepare copy specific widgets
-
- data->silent = gtk_radio_button_new_with_label (group, _("Silently"));
- group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (data->silent));
- gtk_widget_ref (data->silent);
- g_object_set_data_full (G_OBJECT (data->dialog), "silent", data->silent, g_object_unref);
- gtk_widget_show (data->silent);
- gtk_box_pack_start (GTK_BOX (data->dialog->left_vbox), data->silent, FALSE, FALSE, 0);
+ // Create prepare move specific widgets
data->query = gtk_radio_button_new_with_label (group, _("Query First"));
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (data->query));
@@ -95,13 +98,27 @@ void gnome_cmd_prepare_move_dialog_show (GnomeCmdFileSelector *from, GnomeCmdFil
gtk_widget_show (data->query);
gtk_box_pack_start (GTK_BOX (data->dialog->left_vbox), data->query, FALSE, FALSE, 0);
- data->skip = gtk_radio_button_new_with_label (group, _("Skip All"));
+ data->rename = gtk_radio_button_new_with_label (group, _("Rename"));
+ group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (data->rename));
+ gtk_widget_ref (data->rename);
+ g_object_set_data_full (G_OBJECT (data->dialog), "rename", data->rename, g_object_unref);
+ gtk_widget_show (data->rename);
+ gtk_box_pack_start (GTK_BOX (data->dialog->left_vbox), data->rename, FALSE, FALSE, 0);
+
+ data->skip = gtk_radio_button_new_with_label (group, _("Skip"));
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (data->skip));
gtk_widget_ref (data->skip);
g_object_set_data_full (G_OBJECT (data->dialog), "skip", data->skip, g_object_unref);
gtk_widget_show (data->skip);
gtk_box_pack_start (GTK_BOX (data->dialog->left_vbox), data->skip, FALSE, FALSE, 0);
+ data->silent = gtk_radio_button_new_with_label (group, _("Overwrite silently"));
+ group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (data->silent));
+ gtk_widget_ref (data->silent);
+ g_object_set_data_full (G_OBJECT (data->dialog), "silent", data->silent, g_object_unref);
+ gtk_widget_show (data->silent);
+ gtk_box_pack_start (GTK_BOX (data->dialog->left_vbox), data->silent, FALSE, FALSE, 0);
+
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_slist_nth_data (group,
gnome_cmd_data.options.confirm_move_overwrite)), TRUE);
diff --git a/src/dialogs/gnome-cmd-prepare-xfer-dialog.cc b/src/dialogs/gnome-cmd-prepare-xfer-dialog.cc
index eb41c479..217b92f1 100644
--- a/src/dialogs/gnome-cmd-prepare-xfer-dialog.cc
+++ b/src/dialogs/gnome-cmd-prepare-xfer-dialog.cc
@@ -225,20 +225,31 @@ static void on_ok (GtkButton *button, GnomeCmdPrepareXferDialog *dialog)
gnome_cmd_dir_ref (dest_dir);
- gnome_cmd_copy_start (dialog->src_files,
- dest_dir,
- dialog->src_fs->file_list(),
- dest_fn,
- dialog->gFileCopyFlags,
- dialog->overwriteMode,
- NULL, NULL);
-// gnome_cmd_move_start (dialog->src_files,
-// dest_dir,
-// dialog->src_fs->file_list(),
-// dest_fn,
-// dialog->gFileCopyFlags,
-// dialog->xferOverwriteMode,
-// NULL, NULL);
+
+ switch (dialog->gnomeCmdTransferType)
+ {
+ case COPY:
+ gnome_cmd_copy_start (dialog->src_files,
+ dest_dir,
+ dialog->src_fs->file_list(),
+ dest_fn,
+ dialog->gFileCopyFlags,
+ dialog->overwriteMode,
+ NULL, NULL);
+ break;
+ case MOVE:
+ gnome_cmd_move_start (dialog->src_files,
+ dest_dir,
+ dialog->src_fs->file_list(),
+ dest_fn,
+ dialog->gFileCopyFlags,
+ dialog->overwriteMode,
+ NULL, NULL);
+ break;
+ case LINK:
+ default:
+ break;
+ }
bailout:
g_free (dest_path);
diff --git a/src/dialogs/gnome-cmd-prepare-xfer-dialog.h b/src/dialogs/gnome-cmd-prepare-xfer-dialog.h
index ec0cfb66..1d3d5639 100644
--- a/src/dialogs/gnome-cmd-prepare-xfer-dialog.h
+++ b/src/dialogs/gnome-cmd-prepare-xfer-dialog.h
@@ -45,8 +45,8 @@ struct GnomeCmdPrepareXferDialog
GtkWidget *cancel_button;
GFileCopyFlags gFileCopyFlags;
- GnomeVFSXferOptions xferOptions;
GnomeCmdConfirmOverwriteMode overwriteMode;
+ GnomeCmdTransferType gnomeCmdTransferType;
GList *src_files;
GnomeCmdFileSelector *src_fs;
diff --git a/src/gnome-cmd-types.h b/src/gnome-cmd-types.h
index dd8ac744..81206241 100644
--- a/src/gnome-cmd-types.h
+++ b/src/gnome-cmd-types.h
@@ -49,6 +49,14 @@ typedef enum
}GnomeCmdSizeDispMode;
+typedef enum
+{
+ COPY,
+ MOVE,
+ LINK
+}GnomeCmdTransferType;
+
+
typedef enum
{
GNOME_CMD_PERM_DISP_MODE_TEXT,
diff --git a/src/gnome-cmd-xfer.cc b/src/gnome-cmd-xfer.cc
index 3b502035..596236ec 100644
--- a/src/gnome-cmd-xfer.cc
+++ b/src/gnome-cmd-xfer.cc
@@ -296,10 +296,68 @@ static void update_transfer_gui_error_copy (XferData *xferData)
g_free (msg);
}
-static void update_transfer_gui_error_move (XferData *xferData)
+
+static void run_move_overwrite_dialog(XferData *xferData)
{
gint guiResponse = -1;
+ auto problemSrcBasename = get_gfile_attribute_string(xferData->problemSrcGFile,
+ G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
+ auto problemDestBasename = get_gfile_attribute_string(xferData->problemDestGFile,
+ G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
+ auto sourceDetails = get_file_details_string (xferData->problemSrcGFile);
+ auto targetDetails = get_file_details_string (xferData->problemDestGFile);
+ // ToDo: Fix wording for files/folders
+ auto msg = g_strdup_printf (_("Overwrite file:\n\n<b>%s</b>\n<span color='dimgray'
size='smaller'>%s</span>\n\nWith:\n\n<b>%s</b>\n<span color='dimgray' size='smaller'>%s</span>"),
+ problemDestBasename,
+ targetDetails,
+ problemSrcBasename,
+ sourceDetails);
+ g_free (problemSrcBasename);
+ g_free (problemDestBasename);
+ g_free (sourceDetails);
+ g_free (targetDetails);
+ xferData->filesTotal > 1
+ ? guiResponse = run_simple_dialog (
+ *main_win, TRUE, GTK_MESSAGE_ERROR, msg, _("Move problem"),
+ -1, _("Abort"), _("Retry"), _("Replace"), _("Rename"), _("Skip"), _("Replace all"), _("Rename
all"), _("Skip all"), NULL)
+ : guiResponse = run_simple_dialog (
+ *main_win, TRUE, GTK_MESSAGE_ERROR, msg, _("Move problem"),
+ -1, _("Abort"), _("Retry"), _("Replace"), _("Rename"), NULL);
+ switch (guiResponse)
+ {
+ case 0:
+ xferData->problem_action = COPY_ERROR_ACTION_ABORT;
+ break;
+ case 1:
+ xferData->problem_action = COPY_ERROR_ACTION_RETRY;
+ break;
+ case 2:
+ xferData->problem_action = COPY_ERROR_ACTION_REPLACE;
+ break;
+ case 3:
+ xferData->problem_action = COPY_ERROR_ACTION_RENAME;
+ break;
+ case 4:
+ xferData->problem_action = COPY_ERROR_ACTION_SKIP;
+ break;
+ case 5:
+ xferData->problem_action = COPY_ERROR_ACTION_REPLACE_ALL;
+ break;
+ case 6:
+ xferData->problem_action = COPY_ERROR_ACTION_RENAME_ALL;
+ break;
+ case 7:
+ xferData->problem_action = COPY_ERROR_ACTION_SKIP_ALL;
+ break;
+ default:
+ xferData->problem_action = COPY_ERROR_ACTION_RETRY;
+ break;
+ }
+}
+//ToDo: Merge with 'update_transfer_gui_error_copy'
+static void update_transfer_gui_error_move (XferData *xferData)
+{
gchar *msg = g_strdup_printf (_("Error while transferring ā%sā\n\n%s"),
g_file_peek_path(xferData->problemSrcGFile),
xferData->error->message);
@@ -310,103 +368,29 @@ static void update_transfer_gui_error_move (XferData *xferData)
}
else
{
- if (xferData->currentFileType == G_FILE_TYPE_DIRECTORY)
+ gdk_threads_enter ();
+ switch(xferData->overwriteMode)
{
- gdk_threads_enter ();
- g_list_length(xferData->srcGFileList) > 1
- ? guiResponse = run_simple_dialog (
- *main_win, TRUE, GTK_MESSAGE_ERROR, msg, _("Move problem"),
- -1, _("Abort"), _("Retry"), _("Copy into"), _("Rename"), _("Rename all"), _("Skip"), _("Skip
all"), NULL)
- : guiResponse = run_simple_dialog (
- *main_win, TRUE, GTK_MESSAGE_ERROR, msg, _("Move problem"),
- -1, _("Abort"), _("Retry"), _("Copy into"), _("Rename"), NULL);
- gdk_threads_leave ();
- switch (guiResponse)
- {
- case 0:
- xferData->problem_action = COPY_ERROR_ACTION_ABORT;
- break;
- case 1:
- xferData->problem_action = COPY_ERROR_ACTION_RETRY;
- break;
- case 2:
- xferData->problem_action = COPY_ERROR_ACTION_COPY_INTO;
- break;
- case 3:
- xferData->problem_action = COPY_ERROR_ACTION_RENAME;
- break;
- case 4:
- xferData->problem_action = COPY_ERROR_ACTION_RENAME_ALL;
- break;
- case 5:
- xferData->problem_action = COPY_ERROR_ACTION_SKIP;
- break;
- case 6:
- xferData->problem_action = COPY_ERROR_ACTION_SKIP_ALL;
- break;
- default:
- xferData->problem_action = COPY_ERROR_ACTION_RETRY;
- break;
- }
- }
- if (xferData->currentFileType == G_FILE_TYPE_REGULAR)
- {
- auto problemSrcBasename = get_gfile_attribute_string(xferData->problemSrcGFile,
- G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
- auto problemDestBasename = get_gfile_attribute_string(xferData->problemDestGFile,
- G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
- auto sourceDetails = get_file_details_string (xferData->problemSrcGFile);
- auto targetDetails = get_file_details_string (xferData->problemDestGFile);
- g_free(msg);
- msg = g_strdup_printf (_("Overwrite file:\n\n<b>%s</b>\n<span color='dimgray'
size='smaller'>%s</span>\n\nWith:\n\n<b>%s</b>\n<span color='dimgray' size='smaller'>%s</span>"),
- problemDestBasename,
- targetDetails,
- problemSrcBasename,
- sourceDetails);
- g_free (problemSrcBasename);
- g_free (problemDestBasename);
- g_free (sourceDetails);
- g_free (targetDetails);
- gdk_threads_enter ();
- xferData->filesTotal > 1
- ? guiResponse = run_simple_dialog (
- *main_win, TRUE, GTK_MESSAGE_ERROR, msg, _("Copy problem"),
- -1, _("Abort"), _("Retry"), _("Replace"), _("Rename"), _("Skip"), _("Replace all"),
_("Rename all"), _("Skip all"), NULL)
- : guiResponse = run_simple_dialog (
- *main_win, TRUE, GTK_MESSAGE_ERROR, msg, _("Copy problem"),
- -1, _("Abort"), _("Retry"), _("Replace"), _("Rename"), NULL);
- gdk_threads_leave ();
- switch (guiResponse)
- {
- case 0:
- xferData->problem_action = COPY_ERROR_ACTION_ABORT;
- break;
- case 1:
- xferData->problem_action = COPY_ERROR_ACTION_RETRY;
- break;
- case 2:
- xferData->problem_action = COPY_ERROR_ACTION_REPLACE;
- break;
- case 3:
- xferData->problem_action = COPY_ERROR_ACTION_RENAME;
- break;
- case 4:
- xferData->problem_action = COPY_ERROR_ACTION_SKIP;
- break;
- case 5:
- xferData->problem_action = COPY_ERROR_ACTION_REPLACE_ALL;
- break;
- case 6:
- xferData->problem_action = COPY_ERROR_ACTION_RENAME_ALL;
- break;
- case 7:
- xferData->problem_action = COPY_ERROR_ACTION_SKIP_ALL;
- break;
- default:
- xferData->problem_action = COPY_ERROR_ACTION_RETRY;
- break;
- }
+ case GNOME_CMD_CONFIRM_OVERWRITE_SKIP_ALL:
+ xferData->problem_action = COPY_ERROR_ACTION_SKIP_ALL;
+ break;
+ case GNOME_CMD_CONFIRM_OVERWRITE_RENAME_ALL:
+ xferData->problem_action = COPY_ERROR_ACTION_RENAME_ALL;
+ break;
+ case GNOME_CMD_CONFIRM_OVERWRITE_SILENTLY:
+ // Note: When doing a native move operation, there is no option to
+ // move a folder into another folder like it is available for the copy
+ // process. The reason is that in the former case, we don't step recursively
+ // through the subdirectories. That's why we only offer a 'replace', but no
+ // 'copy into' when moving folders.
+ xferData->problem_action = COPY_ERROR_ACTION_REPLACE_ALL;
+ break;
+ case GNOME_CMD_CONFIRM_OVERWRITE_QUERY:
+ default:
+ run_move_overwrite_dialog(xferData);
+ break;
}
+ gdk_threads_leave ();
}
g_free (msg);
}
@@ -1109,9 +1093,12 @@ gnome_cmd_move_gfile_recursive (GFile *srcGFile,
g_free(xferData->curSrcFileName);
xferData->curSrcFileName = get_gfile_attribute_string(srcGFile, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
+ xferData->currentFileType = g_file_query_file_type(srcGFile, G_FILE_QUERY_INFO_NONE, nullptr);
+
if(!g_file_move(srcGFile, destGFile, copyFlags, nullptr, update_transferred_data, xferDataPointer,
&tmpError))
{
if(g_file_query_file_type(srcGFile, G_FILE_QUERY_INFO_NONE, nullptr) == G_FILE_TYPE_DIRECTORY
+ && g_file_query_exists(destGFile, nullptr)
&& g_error_matches(tmpError, G_IO_ERROR, G_IO_ERROR_WOULD_RECURSE))
{
g_message("Folder could not be copied natively, trying a copy-delete...");
@@ -1151,10 +1138,64 @@ gnome_cmd_move_gfile_recursive (GFile *srcGFile,
}
else
{
- g_propagate_error(&(xferData->error), tmpError);
- xferData->problemSrcGFile = g_file_dup(srcGFile);
- xferData->problemDestGFile = g_file_dup(destGFile);
- xfer_progress_update(xferData);
+ // If G_FILE_COPY_OVERWRITE is not specified (i.e. when not 'Overwrite silently' is selected)
+ // and the target exists and is a file, then the error G_IO_ERROR_EXISTS is returned.
+ if(g_error_matches(tmpError, G_IO_ERROR, G_IO_ERROR_EXISTS))
+ {
+ g_propagate_error(&(xferData->error), tmpError);
+ xferData->problemSrcGFile = g_file_dup(srcGFile);
+ xferData->problemDestGFile = g_file_dup(destGFile);
+ xfer_progress_update(xferData);
+
+ guint copyFlagsTemp = copyFlags;
+
+ switch (xferData->problem_action)
+ {
+ case COPY_ERROR_ACTION_RETRY:
+ xferData->problem_action = COPY_ERROR_ACTION_NO_ACTION_YET;
+ return gnome_cmd_move_gfile_recursive(srcGFile, destGFile, copyFlags, xferData);
+ case COPY_ERROR_ACTION_REPLACE:
+ xferData->problem_action = COPY_ERROR_ACTION_NO_ACTION_YET;
+ copyFlagsTemp = copyFlags | G_FILE_COPY_OVERWRITE;
+ gnome_cmd_move_gfile_recursive(srcGFile, destGFile, (GFileCopyFlags) copyFlagsTemp,
xferData);
+ break;
+ case COPY_ERROR_ACTION_REPLACE_ALL:
+ copyFlagsTemp = copyFlags | G_FILE_COPY_OVERWRITE;
+ gnome_cmd_move_gfile_recursive(srcGFile, destGFile, (GFileCopyFlags) copyFlagsTemp,
xferData);
+ break;
+ case COPY_ERROR_ACTION_RENAME:
+ xferData->problem_action = COPY_ERROR_ACTION_NO_ACTION_YET;
+ set_new_nonexisting_dest_gfile(srcGFile, &destGFile, xferData);
+ // ToDo: Handle tmpError, also on other occurences!
+ g_file_move(srcGFile, destGFile, copyFlags, nullptr, update_transferred_data,
xferDataPointer, &tmpError);
+ break;
+ case COPY_ERROR_ACTION_RENAME_ALL:
+ set_new_nonexisting_dest_gfile(srcGFile, &destGFile, xferData);
+ g_file_move(srcGFile, destGFile, copyFlags, nullptr, update_transferred_data,
xferDataPointer, &tmpError);
+ break;
+ case COPY_ERROR_ACTION_SKIP:
+ xferData->problem_action = COPY_ERROR_ACTION_NO_ACTION_YET;
+ break;
+ case COPY_ERROR_ACTION_SKIP_ALL:
+ return true;
+ // ToDo: Copy into can only be selected in case of copying a directory into an
+ // already exising directory, so we are ignoring this here because we deal with
+ // moving files in this if branch.
+ case COPY_ERROR_ACTION_COPY_INTO:
+ case COPY_ERROR_ACTION_ABORT:
+ return false;
+ case COPY_ERROR_ACTION_NO_ACTION_YET:
+ default:
+ break;
+ }
+ }
+ else
+ {
+ g_propagate_error(&(xferData->error), tmpError);
+ xferData->problemSrcGFile = g_file_dup(srcGFile);
+ xferData->problemDestGFile = g_file_dup(destGFile);
+ xfer_progress_update(xferData);
+ }
}
}
else
@@ -1165,6 +1206,12 @@ gnome_cmd_move_gfile_recursive (GFile *srcGFile,
xferData->problem_action = COPY_ERROR_ACTION_NO_ACTION_YET;
}
+ if(xferData->problem_action == COPY_ERROR_ACTION_RETRY)
+ {
+ xferData->problem_action = COPY_ERROR_ACTION_NO_ACTION_YET;
+ gnome_cmd_move_gfile_recursive(srcGFile, destGFile, copyFlags, xferData);
+ }
+
return true;
}
diff --git a/src/gnome-cmd-xfer.h b/src/gnome-cmd-xfer.h
index 7b35d54c..3865d4a1 100644
--- a/src/gnome-cmd-xfer.h
+++ b/src/gnome-cmd-xfer.h
@@ -40,20 +40,13 @@ enum COPY_ERROR_ACTION
COPY_ERROR_ACTION_REPLACE_ALL
};
-enum TRANSFER_TYPE
-{
- COPY,
- MOVE,
- LINK
-};
-
struct XferData
{
GFileCopyFlags copyFlags;
GnomeCmdConfirmOverwriteMode overwriteMode;
GnomeVFSXferOptions xferOptions;
GnomeVFSAsyncHandle *handle;
- TRANSFER_TYPE transferType{COPY};
+ GnomeCmdTransferType transferType{COPY};
// Source and target GFile's. The first srcGFile should be transfered to the first destGFile and so on...
GList *srcGFileList;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]