[gvfs] Bug 610259 – Handle readonly+delete devices



commit 1a18a82314a89d9ef22798261ed56de78175d3bd
Author: Marcus Meissner <meissner suse de>
Date:   Fri Feb 19 15:15:00 2010 -0500

    Bug 610259 â?? Handle readonly+delete devices
    
    https://bugzilla.gnome.org/show_bug.cgi?id=610259
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 daemon/gvfsbackendgphoto2.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/daemon/gvfsbackendgphoto2.c b/daemon/gvfsbackendgphoto2.c
index 45d030a..1182748 100644
--- a/daemon/gvfsbackendgphoto2.c
+++ b/daemon/gvfsbackendgphoto2.c
@@ -195,6 +195,8 @@ struct _GVfsBackendGphoto2
 
   /* whether we can write to the device */
   gboolean can_write;
+  /* whether we can delete files from to the device */
+  gboolean can_delete;
 
   /* This lock protects all members in this class that are not
    * used both on the main thread and on the IO thread. 
@@ -1135,7 +1137,7 @@ file_get_info (GVfsBackendGphoto2 *gphoto2_backend,
       g_object_unref (icon);
       g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ, TRUE);
       g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE, gphoto2_backend->can_write);
-      g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE, gphoto2_backend->can_write);
+      g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE, gphoto2_backend->can_delete);
       g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE, TRUE);
       g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH, FALSE);
       g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME, FALSE); 
@@ -1187,7 +1189,7 @@ file_get_info (GVfsBackendGphoto2 *gphoto2_backend,
           g_file_info_set_size (info, 0);
           g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ, TRUE);
           g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE, gphoto2_backend->can_write);
-          g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE, gphoto2_backend->can_write);
+          g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE, gphoto2_backend->can_delete);
           g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE, TRUE);
           g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH, FALSE);
           g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME, gphoto2_backend->can_write); 
@@ -1280,7 +1282,7 @@ file_get_info (GVfsBackendGphoto2 *gphoto2_backend,
 
   g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ, TRUE);
   g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE, gphoto2_backend->can_write);
-  g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE, gphoto2_backend->can_write);
+  g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE, gphoto2_backend->can_delete);
   g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE, FALSE);
   g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH, FALSE);
   g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME, gphoto2_backend->can_write); 
@@ -1689,6 +1691,7 @@ do_mount (GVfsBackend *backend,
   g_free (fuse_name);
 
   gphoto2_backend->can_write = FALSE;
+  gphoto2_backend->can_delete = FALSE;
   rc = gp_camera_get_storageinfo (gphoto2_backend->camera, &storage_info, &num_storage_info, gphoto2_backend->context);
   if (rc == 0)
     {
@@ -1697,10 +1700,16 @@ do_mount (GVfsBackend *backend,
           if (storage_info[0].fields & GP_STORAGEINFO_ACCESS && storage_info[0].access == GP_STORAGEINFO_AC_READWRITE)
             {
               gphoto2_backend->can_write = TRUE;
+              gphoto2_backend->can_delete = TRUE;
+            }
+          if (storage_info[0].fields & GP_STORAGEINFO_ACCESS && storage_info[0].access == GP_STORAGEINFO_AC_READONLY_WITH_DELETE)
+            {
+              gphoto2_backend->can_delete = TRUE;
             }
         }
     }
   DEBUG ("  can_write = %d", gphoto2_backend->can_write);
+  DEBUG ("  can_delete = %d", gphoto2_backend->can_delete);
 
   g_vfs_job_succeeded (G_VFS_JOB (job));
 
@@ -2870,7 +2879,7 @@ do_delete (GVfsBackend *backend,
   name = NULL;
   dir_name = NULL;
 
-  if (!gphoto2_backend->can_write)
+  if (!gphoto2_backend->can_delete)
     {
       g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR,
                         G_IO_ERROR_NOT_SUPPORTED,



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