gvfs/0003-Silently-drop-eject-error-messages-when-detaching-dr.patch
Bastien Nocera ec003f6253 - Fix crasher in ObexFTP (#528181)
- Don't always overwrite on trash restore
- Separate "Safely Remove Drive" from "Eject"
- Don't advertise can_poll for drives not using removable media
- Disallow mounting empty drives
- Disallow ejecting empty drives
- Silently drop eject error messages when detaching drive
2009-10-14 13:40:05 +00:00

49 lines
1.8 KiB
Diff

From 6d7f1a8a842376be8f72cc1fc90fc3101e9752a3 Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com>
Date: Fri, 2 Oct 2009 15:35:41 +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 3509382..eb70d75 100644
--- a/monitor/gdu/ggdudrive.c
+++ b/monitor/gdu/ggdudrive.c
@@ -648,6 +648,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)
{
@@ -658,8 +670,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