diff options
author | Lionel Landwerlin <lionel.g.landwerlin@linux.intel.com> | 2011-01-28 16:33:12 +0000 |
---|---|---|
committer | Arnel A. Borja <arnelborja@src.gnome.org> | 2013-08-31 00:56:46 +0800 |
commit | 8841c7905a08eb5a7c3469f6d6ce3be3756b716d (patch) | |
tree | c055acff308ca35a6c8f2564a1318cf3cf48b551 | |
parent | ff0903194befc5cf0f9fe7d4efa07237cf54fdeb (diff) | |
download | libmediaart-8841c7905a08eb5a7c3469f6d6ce3be3756b716d.tar.gz |
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 <lionel.g.landwerlin@linux.intel.com>
-rw-r--r-- | src/libtracker-miner/tracker-storage.c | 21 |
1 files 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; } } |