The attached patch ensures that CDs are copied with r/w permissions by passing GNOME_VFS_XFER_TARGET_DEFAULT_PERMS to the Xfer operation if one of the source URIs is on a CD-ROM, or another read-only location. This has to wait until after the code freeze, and fixes bug 167102 [1]. [1] http://bugzilla.gnome.org/show_bug.cgi?id=167102# -- 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.206
diff -u -p -r1.206 nautilus-file-operations.c
--- libnautilus-private/nautilus-file-operations.c 16 Feb 2006 23:58:03 -0000 1.206
+++ libnautilus-private/nautilus-file-operations.c 9 Mar 2006 21:38:06 -0000
@@ -1875,12 +1875,14 @@ nautilus_file_operations_copy_move (cons
TransferInfo *transfer_info;
SyncTransferInfo *sync_transfer_info;
+ GnomeVFSVolume *volume;
GnomeVFSResult result;
gboolean target_is_trash;
gboolean duplicate;
gboolean target_is_mapping;
gboolean have_nonmapping_source;
gboolean have_nonlocal_source;
+ gboolean have_readonly_source;
IconPositionIterator *icon_position_iterator;
@@ -1914,6 +1916,7 @@ nautilus_file_operations_copy_move (cons
target_uri_list = NULL;
have_nonlocal_source = FALSE;
have_nonmapping_source = FALSE;
+ have_readonly_source = FALSE;
duplicate = copy_action != GDK_ACTION_MOVE;
for (p = item_uris; p != NULL; p = p->next) {
/* Filter out special Nautilus link files */
@@ -1938,7 +1941,13 @@ nautilus_file_operations_copy_move (cons
if (strcmp (source_uri->method_string, "burn") != 0) {
have_nonmapping_source = TRUE;
}
-
+
+ volume = nautilus_get_enclosing_volume (source_uri);
+ if (volume != NULL && gnome_vfs_volume_is_read_only (volume)) {
+ have_readonly_source = TRUE;
+ }
+ gnome_vfs_volume_unref (volume);
+
/* Note: this could be null if we're e.g. copying the top level file of a web site */
source_dir_uri = gnome_vfs_uri_get_parent (source_uri);
target_uri = NULL;
@@ -1994,6 +2003,10 @@ nautilus_file_operations_copy_move (cons
* for target files.
*/
move_options |= GNOME_VFS_XFER_USE_UNIQUE_NAMES;
+ }
+
+ if (have_readonly_source) {
+ move_options |= GNOME_VFS_XFER_TARGET_DEFAULT_PERMS;
}
/* List may be NULL if we filtered all items out */
Index: libnautilus-private/nautilus-file-utilities.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-utilities.c,v
retrieving revision 1.128
diff -u -p -r1.128 nautilus-file-utilities.c
--- libnautilus-private/nautilus-file-utilities.c 12 Dec 2005 16:59:10 -0000 1.128
+++ libnautilus-private/nautilus-file-utilities.c 9 Mar 2006 21:38:06 -0000
@@ -39,6 +39,8 @@
#include <libgnomevfs/gnome-vfs-ops.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-utils.h>
+#include <libgnomevfs/gnome-vfs-volume.h>
+#include <libgnomevfs/gnome-vfs-volume-monitor.h>
#include <unistd.h>
#include <stdlib.h>
@@ -581,6 +583,64 @@ nautilus_get_uri_shortname_for_display (
}
return name;
+}
+
+/* FIXME resolve basename symlinks before comparing URIs?
+ * We may wrongly match a volume, or wrongly not match it.
+ */
+GnomeVFSVolume *
+nautilus_get_enclosing_volume (GnomeVFSURI *uri)
+{
+ GnomeVFSVolume *volume, *one_volume;
+ GList *l, *list;
+ char *one_uri;
+ GnomeVFSURI *one_vfs_uri, *potential_vfs_uri;
+
+ g_assert (uri != NULL);
+
+ volume = NULL;
+ potential_vfs_uri = NULL;
+
+ list = gnome_vfs_volume_monitor_get_mounted_volumes (gnome_vfs_get_volume_monitor ());
+
+ for (l = list; l != NULL; l = l->next) {
+ one_volume = l->data;
+
+ one_uri = gnome_vfs_volume_get_activation_uri (one_volume);
+ if (one_uri == NULL) {
+ continue;
+ }
+
+ one_vfs_uri = gnome_vfs_uri_new (one_uri);
+ if (one_vfs_uri == NULL) {
+ g_free (one_uri);
+ continue;
+ }
+
+ if (gnome_vfs_uri_is_parent (one_vfs_uri, uri, TRUE) &&
+ (potential_vfs_uri == NULL ||
+ gnome_vfs_uri_is_parent (potential_vfs_uri, one_vfs_uri, TRUE))) {
+ if (potential_vfs_uri != NULL) {
+ gnome_vfs_uri_unref (potential_vfs_uri);
+ gnome_vfs_volume_unref (volume);
+ }
+
+ potential_vfs_uri = gnome_vfs_uri_ref (one_vfs_uri);
+ volume = gnome_vfs_volume_ref (one_volume);
+ }
+
+ gnome_vfs_uri_unref (one_vfs_uri);
+ g_free (one_uri);
+ }
+
+ if (potential_vfs_uri != NULL) {
+ gnome_vfs_uri_unref (potential_vfs_uri);
+ }
+
+ g_list_foreach (list, (GFunc) gnome_vfs_volume_unref, NULL);
+ g_list_free (list);
+
+ return volume;
}
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
Index: libnautilus-private/nautilus-file-utilities.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-utilities.h,v
retrieving revision 1.58
diff -u -p -r1.58 nautilus-file-utilities.h
--- libnautilus-private/nautilus-file-utilities.h 12 Dec 2005 16:59:10 -0000 1.58
+++ libnautilus-private/nautilus-file-utilities.h 9 Mar 2006 21:38:06 -0000
@@ -26,6 +26,7 @@
#define NAUTILUS_FILE_UTILITIES_H
#include <libgnomevfs/gnome-vfs-types.h>
+#include <libgnomevfs/gnome-vfs-volume.h>
#define NAUTILUS_SAVED_SEARCH_EXTENSION ".savedSearch"
#define NAUTILUS_SAVED_SEARCH_MIMETYPE "application/x-gnome-saved-search"
@@ -87,5 +88,7 @@ GList * nautilus_find_all_files_in_gnom
const char *nautilus_get_vfs_method_display_name (char *method);
char * nautilus_get_uri_shortname_for_display (GnomeVFSURI *uri);
+
+GnomeVFSVolume *nautilus_get_enclosing_volume (GnomeVFSURI *uri);
#endif /* NAUTILUS_FILE_UTILITIES_H */
Attachment:
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil