[gvfs] Silently drop eject error messages when detaching drive



commit becda6e9e9f8edb0042c0ca4844228ccfc907a7b
Author: Tomas Bzatek <tbzatek redhat com>
Date:   Tue Oct 13 17:13:02 2009 +0200

    Silently drop eject error messages when detaching drive
    
    If there's no media in drive and yet it's marked as detachable,
    calling eject would cause "no media in drive" error.
    This is the case with my USB SD card reader.

 monitor/gdu/ggdudrive.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/monitor/gdu/ggdudrive.c b/monitor/gdu/ggdudrive.c
index 79c6809..309e18c 100644
--- a/monitor/gdu/ggdudrive.c
+++ b/monitor/gdu/ggdudrive.c
@@ -641,6 +641,18 @@ eject_cb (GduDevice *device,
 {
   GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data);
   GGduDrive *drive;
+  gboolean drive_detachable;
+
+  drive = G_GDU_DRIVE (g_async_result_get_source_object (G_ASYNC_RESULT (simple)));
+  drive_detachable = drive->can_stop == FALSE && drive->start_stop_type == G_DRIVE_START_STOP_TYPE_SHUTDOWN;
+
+  if (error != NULL && error->code == G_IO_ERROR_FAILED &&
+      drive_detachable && ! drive->has_media && drive->is_media_removable)
+    {
+      /* Silently drop the error if there's no media in drive and we're still trying to detach it (see below) */
+      g_error_free (error);
+      error = NULL;
+    }
 
   if (error != NULL)
     {
@@ -651,8 +663,7 @@ eject_cb (GduDevice *device,
       goto out;
     }
 
-  drive = G_GDU_DRIVE (g_async_result_get_source_object (G_ASYNC_RESULT (simple)));
-  if (drive->can_stop == FALSE && drive->start_stop_type == G_DRIVE_START_STOP_TYPE_SHUTDOWN)
+  if (drive_detachable)
     {
       /* If device is not ejectable but it is detachable and we don't support stop(),
        * then also run Detach() after Eject() - see update_drive() for details for why...



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