From 35d8fdbcfad3fa00871d2a327ad3c4510dd15d8b Mon Sep 17 00:00:00 2001
From: Benedikt Meurer <benny@xfce.org>
Date: Sat, 18 Mar 2006 12:09:27 +0000
Subject: [PATCH] 2006-03-18	Benedikt Meurer <benny@xfce.org>

	* thunar-vfs/thunar-vfs-xfer.c: Make sure the user can always read and
	  write copied directories.




(Old svn revision: 20478)
---
 ChangeLog                    |  5 +++++
 thunar-vfs/thunar-vfs-xfer.c | 17 +++++++----------
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 85ce79f30..5310bb2d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-03-18	Benedikt Meurer <benny@xfce.org>
+
+	* thunar-vfs/thunar-vfs-xfer.c: Make sure the user can always read and
+	  write copied directories.
+
 2006-03-16	Benedikt Meurer <benny@xfce.org>
 
 	* thunar-vfs/thunar-vfs-volume.c(thunar_vfs_volume_lookup_icon_name):
diff --git a/thunar-vfs/thunar-vfs-xfer.c b/thunar-vfs/thunar-vfs-xfer.c
index e67208735..f0c993650 100644
--- a/thunar-vfs/thunar-vfs-xfer.c
+++ b/thunar-vfs/thunar-vfs-xfer.c
@@ -81,7 +81,7 @@ typedef enum
 
 
 
-static gboolean         tvxc_mounted_readonly           (const gchar          *path);
+static gboolean         tvxc_mounted_readonly           (gint                  fd);
 static void             tvxc_set_error_from_errno       (GError              **error,
                                                          const gchar          *message,
                                                          const gchar          *path);
@@ -133,14 +133,14 @@ static ThunarVfsMonitor *thunar_vfs_xfer_monitor = NULL;
 
 
 static gboolean
-tvxc_mounted_readonly (const gchar *path)
+tvxc_mounted_readonly (gint fd)
 {
 #if defined(HAVE_STATVFS)
   struct statvfs statvfsb;
-  return (statvfs (path, &statvfsb) == 0 && (statvfsb.f_flag & ST_RDONLY) != 0);
+  return (fstatvfs (fd, &statvfsb) == 0 && (statvfsb.f_flag & ST_RDONLY) != 0);
 #elif defined(HAVE_STATFS)
   struct statfs statfsb;
-  return (statfs (path, &statfsb) == 0 && (statfsb.f_flags & MNT_RDONLY) != 0);
+  return (fstatfs (fd, &statfsb) == 0 && (statfsb.f_flags & MNT_RDONLY) != 0);
 #else
   return FALSE;
 #endif
@@ -283,11 +283,8 @@ thunar_vfs_xfer_copy_directory (const gchar          *source_absolute_path,
   /* default to the source dir permissions */
   mode = (source_statb->st_mode & ~S_IFMT);
 
-  /* if the source is located on a rdonly medium or we are not the owner of
-   * the source directory, we automatically chmod +rw the destination file.
-   */
-  if (tvxc_mounted_readonly (source_absolute_path) || source_statb->st_uid != getuid ())
-    mode |= (THUNAR_VFS_FILE_MODE_USR_READ | THUNAR_VFS_FILE_MODE_USR_WRITE);
+  /* always make sure that we can write to newly created directories */
+  mode |= (THUNAR_VFS_FILE_MODE_USR_READ | THUNAR_VFS_FILE_MODE_USR_WRITE);
 
   /* check if the directory exists */
   if (g_file_test (target_absolute_path, G_FILE_TEST_IS_DIR))
@@ -370,7 +367,7 @@ thunar_vfs_xfer_copy_regular (const gchar          *source_absolute_path,
   /* if the source is located on a rdonly medium or we are not the owner
    * of the source file, we automatically chmod +rw the destination file.
    */
-  if (tvxc_mounted_readonly (source_absolute_path) || source_statb->st_uid != getuid ())
+  if (tvxc_mounted_readonly (source_fd) || source_statb->st_uid != getuid ())
     mode |= (THUNAR_VFS_FILE_MODE_USR_READ | THUNAR_VFS_FILE_MODE_USR_WRITE);
 
   /* try to open the target file for writing */
-- 
GitLab