gvfs/0003-Silently-drop-eject-error-messages-when-detaching-dr.patch
Tomas Bzatek 3134cdcf0c - HTTP: Support g_file_input_stream_query_info()
- HTTP: Use libsoup header parsing function
- Set correct MIME type for MTP music players
2009-10-16 12:26:34 +00:00

49 lines
1.8 KiB
Diff

From becda6e9e9f8edb0042c0ca4844228ccfc907a7b Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com>
Date: Tue, 13 Oct 2009 17:13:02 +0200
Subject: [PATCH 3/3] 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...
--
1.6.5.rc2