After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 640845 - USB disk not indexed
USB disk not indexed
Status: RESOLVED FIXED
Product: tracker
Classification: Core
Component: Miners
git master
Other Linux
: Normal normal
: ---
Assigned To: tracker-general
Jamie McCracken
Depends on:
Blocks:
 
 
Reported: 2011-01-28 18:04 UTC by Lionel Landwerlin
Modified: 2011-02-17 11:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
tracker-miner-fs traces when inserting a USB hard drive (3.41 KB, text/plain)
2011-01-28 18:04 UTC, Lionel Landwerlin
  Details
Patch (1.71 KB, patch)
2011-01-28 18:05 UTC, Lionel Landwerlin
reviewed Details | Review
New patch version (2.42 KB, patch)
2011-02-15 16:22 UTC, Lionel Landwerlin
none Details | Review
New patch version (2.66 KB, patch)
2011-02-15 16:40 UTC, Lionel Landwerlin
reviewed Details | Review
Updated patch after review (2.64 KB, patch)
2011-02-17 11:12 UTC, Lionel Landwerlin
none Details | Review

Description Lionel Landwerlin 2011-01-28 18:04:54 UTC
Created attachment 179533 [details]
tracker-miner-fs traces when inserting a USB hard drive

Hello,

I'm using Tracker to index my USB devices. Unfortunately any of my USB disk manages to be indexed but my USB keys (flash nand on USB connector) all are.

See traces from tracker-miner-fs when connecting my usb hard drive.

This problems comes from the way Tracker considers a device as removable. Currently it relies on the g_drive_is_media_removable() method from GIO which is not a good choice because this method does not tell us whether a device can be disconnected from the system but rather whether a device contains a media that might be removed from it. It maps the removable flag from the kernel block device subsystem.

Attached is a patch that proposes to use the g_unix_mount_guess_should_display() method instead, which is also used by the gnome volume manager to decide whether or not the device must be display in the UI.
Comment 1 Lionel Landwerlin 2011-01-28 18:05:53 UTC
Created attachment 179534 [details] [review]
Patch
Comment 2 Carlos Garnacho 2011-02-14 16:23:29 UTC
Comment on attachment 179534 [details] [review]
Patch

The patch looks fine to me at first sight, but I don't think we need the GDrive anymore in that code section, so there's no need to get/unref it at all
Comment 3 Aleksander Morgado 2011-02-15 08:13:46 UTC
g_unix_mount_guess_should_display() doesn't seem the correct solution here. But g_drive_is_media_removable() isn't either. See these 3 cases I just tested:

g_drive_is_media_removable():
 * 2GB USB dongle: TRUE
 * 300GB USB HD:   FALSE (wrong for our purposes)
 * sshfs mount:    FALSE

g_unix_mount_guess_should_display():
 * 2GB USB dongle: TRUE
 * 300GB USB HD:   TRUE
 * sshfs mount:    TRUE (wrong for our purposes)

g_unix_mount_guess_should_display() returns TRUE for a sshfs mount, so we cannot assume that every 'non-removable media' (as we consider it) will have should_display() return FALSE.

I wonder now how we could effectively do this. Maybe also playing with g_unix_mount_get_fs_type()? So if should_display() and get_fs_type() is FAT or any other non-remote fs type, then it can be considered as removable... something like that?

Maybe its a good idea to check how the disk mounter applet in gnome shows different icons for the different mounts. Does it use g_unix_mount_guess_icon()? That may give us some hints, as it always seems to do it properly.
Comment 4 Lionel Landwerlin 2011-02-15 16:22:31 UTC
Created attachment 180912 [details] [review]
New patch version
Comment 5 Lionel Landwerlin 2011-02-15 16:40:04 UTC
Created attachment 180915 [details] [review]
New patch version

Add some comment to explain why we keep checking the driver exists.
Comment 6 Aleksander Morgado 2011-02-17 09:27:59 UTC
Review of attachment 180915 [details] [review]:

Seems to be a better approach than our previous g_drive_is_media_removable(), even if I still think that g_unix_mount_guess_should_display() is not a good choice...

Anyway, probably with the changes below is enough for now.

::: src/libtracker-miner/tracker-storage.c
@@ +597,3 @@
 			drive = g_volume_get_drive (volume);
 			if (drive) {
+				GUnixMountEntry *mount_entry = g_unix_mount_at (mount_path, NULL);

To follow with the coding style, it would be:

GUnixMountEntry *mount_entry;
<emptyline>
mount_entry = g_unix_mount_at (mount_path, NULL);

@@ +601,3 @@
+				/* We can't mount/unmount system volumes, so tag
+				 * them as non removable. */
+				is_removable = g_volume_can_mount (volume);

I would merge this in the previous if(), something like:

if (drive && g_volume_can_mount (volume))

So that you only try to get the mount_entry if that already succeeded.

@@ +607,3 @@
+					 * mount points out of /media/ or
+					 * $HOME/. */
+					is_removable &= g_unix_mount_guess_should_display (mount_entry);

If you do the previous fix of merging the can_mount() in the if(), you don't need to "&=", just "=" which is clearer.

@@ +610,3 @@
+
+					g_unix_mount_free (mount_entry);
+				}

And if !mount_entry, please g_debug() the condition so that if any happens to have a case where that branch is accessed, we know about it.
Comment 7 Lionel Landwerlin 2011-02-17 11:12:12 UTC
Created attachment 181114 [details] [review]
Updated patch after review
Comment 8 Aleksander Morgado 2011-02-17 11:43:40 UTC
Tried with all disks I have here and worked ok, so pushed to git master. Thanks for the patch!

This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.