Re: [PATCH] Fix symlink trashing (yet again)



Am Sonntag, den 09.10.2005, 16:26 +0200 schrieb Christian Neumair:
> Am Sonntag, den 09.10.2005, 16:21 +0200 schrieb Christian Neumair:
> > --- libnautilus-private/nautilus-file-operations.c      19 Sep 2005
> > 15:50:57 -0000      1.197
> > +++ libnautilus-private/nautilus-file-operations.c      9 Oct 2005
> > 14:12:45 -0000
> > @@ -1,4 +1,3 @@
> > -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8
> > -*- */
> >  
> >  /* nautilus-file-operations.c - Nautilus file operations.
> >  
> > @@ -1857,20 +1856,27 @@ nautilus_file_operations_copy_move (cons
> 
> I have no clue how this ended up in the diff. Reattaching modified
> patch.

This one even doesn't break simple copy or move operations, and adds two
asserts.

-- 
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.197
diff -u -p -r1.197 nautilus-file-operations.c
--- libnautilus-private/nautilus-file-operations.c	19 Sep 2005 15:50:57 -0000	1.197
+++ libnautilus-private/nautilus-file-operations.c	11 Oct 2005 11:03:38 -0000
@@ -1858,17 +1857,31 @@ nautilus_file_operations_copy_move (cons
 		source_dir_uri = gnome_vfs_uri_get_parent (source_uri);
 		target_uri = NULL;
 		if (target_dir != NULL) {
+			GnomeVFSURI *trash_find_uri;
+
 			if (target_is_trash) {
-				result = gnome_vfs_find_directory (source_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
+				/* source_uri may be a symlink, which is resolved when finding the trash directory.
+				 * Therefore, we use its parent dir if available */
+				trash_find_uri = source_dir_uri != NULL ? source_dir_uri : source_uri;
+				g_assert (trash_find_uri != NULL);
+
+				result = gnome_vfs_find_directory (trash_find_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 (result != GNOME_VFS_OK) {
+					char *trash_find_text_uri;
+
+					g_assert (target_dir_uri == NULL);
+
+					trash_find_text_uri = gnome_vfs_uri_to_string (trash_find_uri, GNOME_VFS_URI_HIDE_NONE);
+					g_warning ("Unable to find trash for \"%s\": %s. Please file a bug report.",
+						   trash_find_text_uri,
+						   gnome_vfs_result_to_string (result));
+					g_free (trash_find_text_uri);
+				}
 			}
+
 			if (target_dir_uri != NULL) {
 				target_uri = append_basename (target_dir_uri, source_uri);
 			}

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]