[PATCH] Fix broken symlink deletion on activation



If a symlink is broken, gnome_vfs_find_directory fails because the full
symlink resolution returns GNOME_VFS_ERROR_NOT_FOUND. The attached patch
ensures that in that case the parent dir URI of the symlink is used.
This seem to fix the issue where "Move to Trash" didn't do anything for
broken symlinks on activation.

-- 
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-file-operations.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-operations.c,v
retrieving revision 1.196
diff -u -p -r1.196 nautilus-file-operations.c
--- libnautilus-private/nautilus-file-operations.c	25 Aug 2005 08:57:47 -0000	1.196
+++ libnautilus-private/nautilus-file-operations.c	19 Sep 2005 11:14:10 -0000
@@ -1859,8 +1859,15 @@ nautilus_file_operations_copy_move (cons
 		target_uri = NULL;
 		if (target_dir != NULL) {
 			if (target_is_trash) {
-				gnome_vfs_find_directory (source_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
-							  &target_dir_uri, FALSE, FALSE, 0777);			
+				result = gnome_vfs_find_directory (source_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
+								   &target_dir_uri, FALSE, FALSE, 0777);
+				if (result == GNOME_VFS_ERROR_NOT_FOUND && source_dir_uri != NULL) {
+					/* source_uri may be a broken symlink */
+					result = gnome_vfs_find_directory (source_dir_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
+									   &target_dir_uri, FALSE, FALSE, 0777);
+				}
+
+				result = GNOME_VFS_OK;
 			}
 			if (target_dir_uri != NULL) {
 				target_uri = append_basename (target_dir_uri, source_uri);
@@ -2712,6 +2719,8 @@ nautilus_file_operations_empty_trash (Gt
 void
 nautilus_self_check_file_operations (void)
 {
+	setlocale (LC_MESSAGES, "C");
+
 	/* test the next duplicate name generator */
 	EEL_CHECK_STRING_RESULT (get_duplicate_name (" (copy)", 1), " (another copy)");
 	EEL_CHECK_STRING_RESULT (get_duplicate_name ("foo", 1), "foo (copy)");
@@ -2754,6 +2763,8 @@ nautilus_self_check_file_operations (voi
 	EEL_CHECK_STRING_RESULT (get_duplicate_name ("foo (122nd copy).txt", 1), "foo (123rd copy).txt");
 	EEL_CHECK_STRING_RESULT (get_duplicate_name ("foo (123rd copy)", 1), "foo (124th copy)");
 	EEL_CHECK_STRING_RESULT (get_duplicate_name ("foo (123rd copy).txt", 1), "foo (124th copy).txt");
+
+	setlocale (LC_MESSAGES, "");
 }
 
 #endif

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]