summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2017-10-25 20:28:22 +0200
committerOndrej Holy <oholy@redhat.com>2017-10-26 08:49:51 +0200
commit0c7f803b592a2f472714c5e7c97b92515aef0620 (patch)
treee26baf1d100fe85ce88f41f1ff46cac1bd9268bc
parent57a02264ce572a1338ec89876d95690195b87aa8 (diff)
downloadgvfs-0c7f803b592a2f472714c5e7c97b92515aef0620.tar.gz
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
-rw-r--r--monitor/mtp/gmtpvolumemonitor.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/monitor/mtp/gmtpvolumemonitor.c b/monitor/mtp/gmtpvolumemonitor.c
index 50e37cfe..bfd9e29f 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