From 8841c7905a08eb5a7c3469f6d6ce3be3756b716d Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Fri, 28 Jan 2011 16:33:12 +0000 Subject: libtracker-miner,storage: do not rely on g_drive_is_media_removable() Fixes GB#640845 We don't want to rely on the g_drive_is_media_removable() method because it does not tell us whether a device can be disconnected from the system but rather if a device contains a media that might be extracted from it. In fact, this method maps the removable flag from the kernel block device subsystem. If we rely on g_drive_is_media_removable(), most of the USB harddrives are considered as non removable, and are therefor won't be indexed. This patch proposes to check whether or not the mount point is part of the system, and if it's not, we use g_volume_can_mount() method to check whether the filesystem can be mounted which gives us a better clue about whether the related device is removable or not (in the way tracker considers a device from being removable). Signed-off-by: Lionel Landwerlin --- src/libtracker-miner/tracker-storage.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/libtracker-miner/tracker-storage.c b/src/libtracker-miner/tracker-storage.c index 7a83692..3fc5c4c 100644 --- a/src/libtracker-miner/tracker-storage.c +++ b/src/libtracker-miner/tracker-storage.c @@ -591,21 +591,28 @@ mount_add (TrackerStorage *storage, g_free (content_type); } else { - /* Any other removable media will have UUID in the GVolume. - * Note that this also may include some partitions in the machine - * which have GVolumes associated to the GMounts. So, we need to - * explicitly check if the drive is media-removable (machine - * partitions won't be media-removable) */ + /* Any other removable media will have UUID in the + * GVolume. Note that this also may include some + * partitions in the machine which have GVolumes + * associated to the GMounts. We also check a drive + * exists to be sure the device is local. */ GDrive *drive; drive = g_volume_get_drive (volume); + if (drive) { - is_removable = g_drive_is_media_removable (drive); + /* We can't mount/unmount system volumes, so tag + * them as non removable. */ + if (g_volume_can_mount (volume)) { + is_removable = TRUE; + } else { + is_removable = FALSE; + } g_object_unref (drive); } else { /* Note: not sure when this can happen... */ g_debug (" Assuming GDrive has removable media, if wrong report a bug!"); - is_removable = TRUE; + is_removable = FALSE; } } -- cgit v1.2.1