[file-roller] use cp if the destination folder already exists
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [file-roller] use cp if the destination folder already exists
- Date: Sat, 7 Nov 2009 18:28:01 +0000 (UTC)
commit ca25652fbf1b3e16305c97cb076fb3bb4c8bb2d9
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sat Nov 7 19:23:58 2009 +0100
use cp if the destination folder already exists
we prefer mv instead of cp for performance reasons,
but if the destination folder already exists mv
doesn't work correctly.
[bug #590027]
src/eggtreemultidnd.c | 3 +++
src/fr-archive.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 46 insertions(+), 1 deletions(-)
---
diff --git a/src/eggtreemultidnd.c b/src/eggtreemultidnd.c
index 5915d5f..574d190 100644
--- a/src/eggtreemultidnd.c
+++ b/src/eggtreemultidnd.c
@@ -309,6 +309,9 @@ egg_tree_multi_drag_motion_event (GtkWidget *widget,
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
gtk_tree_selection_selected_foreach (selection, selection_foreach, &path_list);
+ if (path_list == NULL)
+ return;
+
path_list = g_list_reverse (path_list);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
diff --git a/src/fr-archive.c b/src/fr-archive.c
index be4c29b..11217f1 100644
--- a/src/fr-archive.c
+++ b/src/fr-archive.c
@@ -2132,12 +2132,52 @@ move_files_to_dir (FrArchive *archive,
const char *source_dir,
const char *dest_dir)
{
+ GList *list;
GList *scan;
+ /* we prefer mv instead of cp for performance reasons,
+ * but if the destination folder already exists mv
+ * doesn't work correctly. (bug #590027) */
+
+ list = g_list_copy (file_list);
+ for (scan = list; scan; /* void */) {
+ GList *next = scan->next;
+ char *filename = scan->data;
+ char *basename;
+ char *destname;
+
+ basename = g_path_get_basename (filename);
+ destname = g_build_filename (dest_dir, basename, NULL);
+ if (g_file_test (destname, G_FILE_TEST_IS_DIR)) {
+ fr_process_begin_command (archive->process, "cp");
+ fr_process_add_arg (archive->process, "-R");
+ if (filename[0] == '/')
+ fr_process_add_arg_concat (archive->process, source_dir, filename, NULL);
+ else
+ fr_process_add_arg_concat (archive->process, source_dir, "/", filename, NULL);
+ fr_process_add_arg (archive->process, dest_dir);
+ fr_process_end_command (archive->process);
+
+ list = g_list_remove_link (list, scan);
+ g_list_free (scan);
+ }
+
+ g_free (destname);
+ g_free (basename);
+
+ scan = next;
+ }
+
+ if (list == NULL)
+ return;
+
+ /* 'list' now contains the files that can be moved without problems */
+
fr_process_begin_command (archive->process, "mv");
fr_process_add_arg (archive->process, "-f");
- for (scan = file_list; scan; scan = scan->next) {
+ for (scan = list; scan; scan = scan->next) {
char *filename = scan->data;
+
if (filename[0] == '/')
fr_process_add_arg_concat (archive->process, source_dir, filename, NULL);
else
@@ -2145,6 +2185,8 @@ move_files_to_dir (FrArchive *archive,
}
fr_process_add_arg (archive->process, dest_dir);
fr_process_end_command (archive->process);
+
+ g_list_free (list);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]