[tracker/mounts-without-volumes: 1/12] Fixes NB#172818: Tracker is not indexing new content on EMMC



commit 109ef3b6d4a2d12d5485ec67a23c681677a3b599
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Tue Jun 8 11:09:42 2010 +0200

    Fixes NB#172818: Tracker is not indexing new content on EMMC
    
    	* If the mount point detected doesn't setup a GVolume (as it
    	is in fstab), then just force a re-check of the directories
    	indexed to see if anything changed.

 src/libtracker-miner/tracker-storage.c |   45 +++++++++++---------
 src/miners/fs/tracker-miner-files.c    |   72 ++++++++++++++++++--------------
 2 files changed, 65 insertions(+), 52 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-storage.c b/src/libtracker-miner/tracker-storage.c
index 90a9b13..d5f40d0 100644
--- a/src/libtracker-miner/tracker-storage.c
+++ b/src/libtracker-miner/tracker-storage.c
@@ -337,11 +337,13 @@ mount_add (TrackerStorage *storage,
 
 	priv = TRACKER_STORAGE_GET_PRIVATE (storage);
 
-	node = mount_add_hierarchy (priv->mounts, uuid, mount_point, removable_device, optical_disc);
-	g_hash_table_insert (priv->mounts_by_uuid, g_strdup (uuid), node);
+	if (uuid) {
+		node = mount_add_hierarchy (priv->mounts, uuid, mount_point, removable_device, optical_disc);
+		g_hash_table_insert (priv->mounts_by_uuid, g_strdup (uuid), node);
+	}
 
-	g_signal_emit (storage, 
-	               signals[MOUNT_POINT_ADDED], 
+	g_signal_emit (storage,
+	               signals[MOUNT_POINT_ADDED],
 	               0,
 	               uuid,
 	               mount_point,
@@ -366,9 +368,9 @@ mount_guess_content_type (GFile    *mount_root,
 	} else {
 		gchar **guess_type;
 		gint i;
-		
+
 		guess_type = g_content_type_guess_for_tree (mount_root);
-		
+
 		for (i = 0; guess_type && guess_type[i]; i++) {
 			if (!g_strcmp0 (guess_type[i], "x-content/image-picturecd")) {
 				/* Images */
@@ -411,7 +413,7 @@ mount_guess_content_type (GFile    *mount_root,
 				break;
 			}
 		}
-		
+
 		if (guess_type) {
 			g_strfreev (guess_type);
 		}
@@ -449,7 +451,7 @@ volume_add (TrackerStorage *storage,
 
 	name = g_volume_get_name (volume);
 	g_debug ("  Volume:'%s' found", name);
-		
+
 	if (!g_volume_should_automount (volume) ||
 	    !g_volume_can_mount (volume)) {
 		g_debug ("    Ignoring, volume can not be automatically mounted or mounted at all");
@@ -463,8 +465,8 @@ volume_add (TrackerStorage *storage,
 		gchar *content_type;
 		gboolean is_multimedia;
 
-		mount = g_volume_get_mount (volume); 
-		
+		mount = g_volume_get_mount (volume);
+
 		if (mount) {
 			file = g_mount_get_root (mount);
 			g_object_unref (mount);
@@ -507,26 +509,26 @@ volume_add (TrackerStorage *storage,
 
 	device_file = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
 	g_debug ("    Device file  : %s", device_file);
-		
-	mount = g_volume_get_mount (volume); 
+
+	mount = g_volume_get_mount (volume);
 
 	if (mount) {
 		GFile *file;
-		
+
 		file = g_mount_get_root (mount);
-		
+
 		mount_point = g_file_get_path (file);
 		g_debug ("    Mount point  : %s", mount_point);
-		
+
 		g_object_unref (file);
 		g_object_unref (mount);
-		
+
 		is_mounted = TRUE;
 	} else {
 		mount_point = NULL;
 		is_mounted = FALSE;
 	}
-	
+
 	g_debug ("    UUID         : %s", uuid);
 	g_debug ("    Mounted      : %s", is_mounted ? "yes" : "no");
 
@@ -566,7 +568,7 @@ drives_setup (TrackerStorage *storage)
 		if (!drive) {
 			continue;
 		}
-		
+
 		volumes = g_drive_get_volumes (drive);
 		name = g_drive_get_name (drive);
 
@@ -658,7 +660,8 @@ mount_added_cb (GVolumeMonitor *monitor,
 		g_free (device_file);
 		g_object_unref (volume);
 	} else {
-		g_message ("  Being ignored because we have no GVolume");
+		g_message ("  Non-Volume mount detected, forcing re-check");
+		mount_add (storage, NULL, mount_point, FALSE, FALSE);
 	}
 
 	g_free (mount_point);
@@ -700,7 +703,7 @@ mount_removed_cb (GVolumeMonitor *monitor,
 		           mount_point);
 
 		g_signal_emit (storage, signals[MOUNT_POINT_REMOVED], 0, info->uuid, mount_point, NULL);
-		
+
 		g_hash_table_remove (priv->mounts_by_uuid, info->uuid);
 		mount_node_free (node);
 	} else {
@@ -811,7 +814,7 @@ tracker_storage_get_device_roots (TrackerStorage     *storage,
  *
  * Returns: a #GSList of strings containing the UUID for devices with
  * @type based on @exact_match. Each element must be freed using
- * g_free() and the list itself through g_slist_free(). 
+ * g_free() and the list itself through g_slist_free().
  **/
 GSList *
 tracker_storage_get_device_uuids (TrackerStorage     *storage,
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 0fdca5f..5043356 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -140,6 +140,7 @@ static void        index_recursive_directories_cb       (GObject              *g
 static void        index_single_directories_cb          (GObject              *gobject,
                                                          GParamSpec           *arg1,
                                                          gpointer              user_data);
+static gboolean    miner_files_force_recheck_idle       (gpointer user_data);
 static void        ignore_directories_cb                (GObject              *gobject,
 							 GParamSpec           *arg1,
 							 gpointer              user_data);
@@ -841,7 +842,6 @@ mount_point_added_cb (TrackerStorage *storage,
 	gchar *urn;
 	gboolean index_removable_devices;
 	gboolean index_optical_discs;
-	gboolean should_crawl;
 
 	priv = TRACKER_MINER_FILES_GET_PRIVATE (miner);
 
@@ -850,40 +850,50 @@ mount_point_added_cb (TrackerStorage *storage,
 
 	g_message ("Added mount point '%s'", mount_point);
 
-	should_crawl = TRUE;
+	if (uuid) {
+		/* We only get UUID if this mount point was actually coming from a
+		 *  proper GVolume (user-mountable). */
 
-	if (removable && !tracker_config_get_index_removable_devices (priv->config)) {
-		g_message ("  Not crawling, removable devices disabled in config");
-		should_crawl = FALSE;
-	}
+		if (removable && !tracker_config_get_index_removable_devices (priv->config)) {
+			g_message ("  Not crawling, removable devices disabled in config");
+		} else if (optical && !tracker_config_get_index_optical_discs (priv->config)) {
+			g_message ("  Not crawling, optical devices discs disabled in config");
+		} else {
+			g_message ("  Adding directory to crawler's queue");
 
-	if (optical && !tracker_config_get_index_optical_discs (priv->config)) {
-		g_message ("  Not crawling, optical devices discs disabled in config");
-		should_crawl = FALSE;
-	}
+			file = g_file_new_for_path (mount_point);
+			g_object_set_qdata_full (G_OBJECT (file),
+			                         priv->quark_mount_point_uuid,
+			                         g_strdup (uuid),
+			                         (GDestroyNotify) g_free);
 
-	if (should_crawl) {
-		g_message ("  Adding directory to crawler's queue");
+			g_object_set_qdata (G_OBJECT (file),
+			                    priv->quark_directory_config_root,
+			                    GINT_TO_POINTER (TRUE));
 
-		file = g_file_new_for_path (mount_point);
-		g_object_set_qdata_full (G_OBJECT (file),
-		                         priv->quark_mount_point_uuid,
-		                         g_strdup (uuid),
-		                         (GDestroyNotify) g_free);
+			tracker_miner_fs_directory_add (TRACKER_MINER_FS (user_data),
+			                                file,
+			                                TRUE);
+			g_object_unref (file);
+		}
 
-		g_object_set_qdata (G_OBJECT (file),
-		                    priv->quark_directory_config_root,
-		                    GINT_TO_POINTER (TRUE));
+		urn = g_strdup_printf (TRACKER_DATASOURCE_URN_PREFIX "%s", uuid);
+		set_up_mount_point (miner, urn, mount_point, TRUE, NULL);
+		g_free (urn);
+	} else {
+		/* If we don't get a UUID, it probably is because the mount point
+		 *  was not really user-mountable (so also not a removable media or
+		 *  optical disk). In this case, we just force a re-check as if the
+		 *  conf had changed, so that if any path inside the mount was
+		 *  configured to be indexed, it's properly updated.
+		 */
 
-		tracker_miner_fs_directory_add (TRACKER_MINER_FS (user_data),
-		                                file,
-		                                TRUE);
-		g_object_unref (file);
+		if (miner->private->force_recheck_id == 0) {
+			/* Set idle so multiple changes in the config lead to one recheck */
+			miner->private->force_recheck_id =
+				g_idle_add (miner_files_force_recheck_idle, miner);
+		}
 	}
-
-	urn = g_strdup_printf (TRACKER_DATASOURCE_URN_PREFIX "%s", uuid);
-	set_up_mount_point (miner, urn, mount_point, TRUE, NULL);
-	g_free (urn);
 }
 
 #if defined(HAVE_UPOWER) || defined(HAVE_HAL)



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