Bug 565610 – Replacing folder with file from within that folder destroys

2009-02-18  Alexander Larsson  <alexl@redhat.com>

	Bug 565610 – Replacing folder with file from within that folder destroys both

        * libnautilus-private/nautilus-file-operations.c:
        (copy_move_file):
	Give a warning when the source would be overwritten by the
	destination on a copy.


svn path=/trunk/; revision=14968
This commit is contained in:
Alexander Larsson 2009-02-18 16:06:40 +00:00 committed by Alexander Larsson
parent 5c243e0b90
commit 100781f806
2 changed files with 44 additions and 0 deletions

View file

@ -1,3 +1,12 @@
2009-02-18 Alexander Larsson <alexl@redhat.com>
Bug 565610 Replacing folder with file from within that folder destroys both
* libnautilus-private/nautilus-file-operations.c:
(copy_move_file):
Give a warning when the source would be overwritten by the
destination on a copy.
2009-02-17 Alexander Larsson <alexl@redhat.com>
* configure.in:

View file

@ -3784,6 +3784,41 @@ copy_move_file (CopyMoveJob *copy_job,
goto out;
}
/* Don't allow copying over the source or one of the parents of the source.
*/
if (test_dir_is_parent (src, dest)) {
if (job->skip_all_error) {
g_error_free (error);
goto out;
}
/* the run_warning() frees all strings passed in automatically */
primary = copy_job->is_move ? g_strdup (_("You cannot move a file over itself."))
: g_strdup (_("You cannot copy a file over itself."));
secondary = g_strdup (_("The source file is overwritten by the destination."));
response = run_warning (job,
primary,
secondary,
NULL,
(source_info->num_files - transfer_info->num_files) > 1,
GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
NULL);
if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
abort_job (job);
} else if (response == 1) { /* skip all */
job->skip_all_error = TRUE;
} else if (response == 2) { /* skip */
/* do nothing */
} else {
g_assert_not_reached ();
}
goto out;
}
retry: