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:55:34 +0200
commit4fe3b0f8d24851145b5ceae10eb3181b2340466b (patch)
treeca3f51223bc614c19690a401b6f3e1f710da95c3
parent16edf95f932653ac6b7493fbad5261b2c4e5502b (diff)
downloadgvfs-4fe3b0f8d24851145b5ceae10eb3181b2340466b.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