patches/gnome-vfs-08-trash-skip-copy.diff
author gheet
Thu, 14 Dec 2006 16:06:52 +0000
changeset 8809 a1af69090bc2
permissions -rw-r--r--
2006-12-14 Ghee Teo <[email protected]> * ORBit2.spec: added metainfo * gnome-vfs.spec: added metainfo * patches/gnome-vfs-03-g11n-i18n-ui.diff: removed upstream * patches/gnome-vfs-04-trash-only-home.diff: renamed * patches/gnome-vfs-05-mount-points-fix.diff: renamed * patches/gnome-vfs-06-trash-files-from-different-filesystem.diff: renamed * patches/gnome-vfs-07-socks-version.diff: renamed * patches/gnome-vfs-08-audio-cd-show-icon.diff: renamed * patches/gnome-vfs-09-trash-skip-copy.diff: renamed * patches/gnome-vfs-10-login_tty.diff: renamed * patches/gnome-vfs-11-krb5-config-no-gssapi.diff: renamed * patches/gnome-vfs-12-hidden.diff: renamed * patches/gnome-vfs-13-acl-permissions.diff: renamed

--- gnome-vfs-2.6.0/libgnomevfs/gnome-vfs-xfer.c	2005-04-13 09:09:29.000000000 +0530
+++ archana-gnome-vfs-2.6.0/libgnomevfs/gnome-vfs-xfer.c	2005-04-13 10:41:54.819357496 +0530
@@ -2115,9 +2115,36 @@ gnome_vfs_xfer_uri_internal (const GList
 			source_uri != NULL;
 			source_uri = source_uri->next, target_uri = target_uri->next) {
 			gboolean same_fs;
+			gboolean is_local;
+			char *trash_dir;
+			GnomeVFSURI *trash_uri;
+			GnomeVFSFileInfo *file_info;
 
 			g_assert (target_dir_uri != NULL);
 
+			/* For local uris, don't set the move option to copy/remove where remove
+			 * can't be done
+			 */
+			file_info = gnome_vfs_file_info_new ();
+
+			trash_dir = g_strconcat (g_get_home_dir (), "/.Trash", NULL);
+			trash_uri = gnome_vfs_uri_new (trash_dir);
+
+			result = gnome_vfs_get_file_info_uri ((GnomeVFSURI *)(source_uri->data),
+							      file_info,
+							      GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS);
+
+			is_local = gnome_vfs_uri_is_local ((GnomeVFSURI *)(source_uri->data));
+
+			if (result == GNOME_VFS_OK && ! strcmp (target_dir_uri->text, trash_uri->text)) {
+				if (is_local && (file_info->permissions & GNOME_VFS_PERM_ACCESS_WRITABLE) != 0) {
+					goto change_operation_move;
+				}
+				else {
+					goto dont_change_operation_move;
+				}
+			}
+change_operation_move:
 			result = gnome_vfs_check_same_fs_uris ((GnomeVFSURI *)source_uri->data, 
 				target_dir_uri, &same_fs);
 
@@ -2126,6 +2153,10 @@ gnome_vfs_xfer_uri_internal (const GList
 			}
 
 			move &= same_fs;
+dont_change_operation_move:
+			g_free (trash_dir);
+			gnome_vfs_uri_unref (trash_uri);
+			gnome_vfs_file_info_unref (file_info);
 		}
 	/*}*/