[gvfs] mtp: Fix volume removal with current udev behavior



commit 0c7f803b592a2f472714c5e7c97b92515aef0620
Author: Ondrej Holy <oholy redhat com>
Date:   Wed Oct 25 20:28:22 2017 +0200

    mtp: Fix volume removal with current udev behavior
    
    UDev events for devices without ID_MTP_DEVICE property are ignored.
    Although ID_MTP_DEVICE seems don't have to be set for device when removing
    and thus the volume is not removed. Let's ignore ID_MTP_DEVICE when removing.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=789491

 monitor/mtp/gmtpvolumemonitor.c |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)
---
diff --git a/monitor/mtp/gmtpvolumemonitor.c b/monitor/mtp/gmtpvolumemonitor.c
index 50e37cf..bfd9e29 100644
--- a/monitor/mtp/gmtpvolumemonitor.c
+++ b/monitor/mtp/gmtpvolumemonitor.c
@@ -208,17 +208,12 @@ on_uevent (GUdevClient *client, gchar *action, GUdevDevice *device, gpointer use
 
   g_debug ("on_uevent: action=%s, device=%s", action, g_udev_device_get_device_file(device));
 
-  /* filter out uninteresting events */
-  if (!g_udev_device_has_property (device, "ID_MTP_DEVICE"))
-    {
-      g_debug ("on_uevent: discarding, not ID_MTP");
-      return;
-    }
-
-  if (strcmp (action, "add") == 0)
-     gudev_add_device (monitor, device, TRUE); 
-  else if (strcmp (action, "remove") == 0)
-     gudev_remove_device (monitor, device); 
+  if (g_strcmp0 (action, "add") == 0 && g_udev_device_has_property (device, "ID_MTP_DEVICE"))
+    gudev_add_device (monitor, device, TRUE);
+  else if (g_strcmp0 (action, "remove") == 0 && g_udev_device_get_device_file (device) != NULL)
+    gudev_remove_device (monitor, device);
+  else
+    g_debug ("on_uevent: discarding");
 }
 
 static void


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