[tracker] libtracker-miner, storage: do not rely on g_drive_is_media_removable()



commit f0089d124ef5028fb5b2308bc42d60482a5017c9
Author: Lionel Landwerlin <lionel g landwerlin linux intel com>
Date:   Fri Jan 28 16:33:12 2011 +0000

    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>

 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;
 			}
 		}
 



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