[tracker/harmattan-pre-signal-updates: 433/1380] debian: Added patch 01-mounts-without-volumes for release 0.9.8-2maemo1



commit cb9396ddf7e5fbf740f0261876af578024c811a7
Author: Martyn Russell <martyn lanedo com>
Date:   Tue Jun 15 10:22:52 2010 +0100

    debian: Added patch 01-mounts-without-volumes for release 0.9.8-2maemo1

 debian/changelog                               |   10 +
 debian/patches/01-mounts-without-volumes.patch | 1393 ++++++++++++++++++++++++
 2 files changed, 1403 insertions(+), 0 deletions(-)
---
diff --git a/debian/changelog b/debian/changelog
index 8f94eda..72ac27b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,13 @@
+tracker (0.9.8-2maemo1) unstable; urgency=low
+
+  * Added 01-mounts-without-volumes.patch to fix various volume breakages ahead of this week's release
+  * Fixes: NB#172818, Tracker is not indexing new content on EMMC
+  * Fixes: GB#621183, When mounting volume 2nd time, inotify watches don't work any more
+  * Fixes: GB#621112, Resources not deleted from store when files removed from removable media
+  * Fixes: GB#621001, tracker-miner-fs fails to initialize active mount points if CD name has whitespaces
+
+ -- Martyn Russell <martyn lanedo com>  Tue, 15 June 2010 10:30:00 +0000
+
 tracker (0.9.8-1maemo1) unstable; urgency=low
 
   * Fixes: NB#173206, Images and videos should both have the key 'nfo:device' with the same information
diff --git a/debian/patches/01-mounts-without-volumes.patch b/debian/patches/01-mounts-without-volumes.patch
new file mode 100644
index 0000000..dac74f0
--- /dev/null
+++ b/debian/patches/01-mounts-without-volumes.patch
@@ -0,0 +1,1393 @@
+diff --git a/configure.ac b/configure.ac
+index 0a0580d..614a530 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -183,7 +183,8 @@ PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= $GLIB_REQUIRED])
+ AC_SUBST(GMODULE_CFLAGS)
+ AC_SUBST(GMODULE_LIBS)
+ 
+-PKG_CHECK_MODULES(GIO, [gio-2.0 >= $GLIB_REQUIRED])
++# Check for GIO 2.0
++PKG_CHECK_MODULES(GIO, [gio-2.0 >= $GLIB_REQUIRED gio-unix-2.0 >= $GLIB_REQUIRED])
+ AC_SUBST(GIO_CFLAGS)
+ AC_SUBST(GIO_LIBS)
+ 
+diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
+index 88403a6..01b1fee 100644
+--- a/src/libtracker-miner/tracker-miner-fs.c
++++ b/src/libtracker-miner/tracker-miner-fs.c
+@@ -127,12 +127,15 @@ struct TrackerMinerFSPrivate {
+ 	GFile          *current_parent;
+ 	gchar          *current_parent_urn;
+ 
+-	/* Folder contents' mtime cache */
++	/* URI mtime cache */
+ 	GHashTable     *mtime_cache;
+ 
+ 	/* File -> iri cache */
+ 	GHashTable     *iri_cache;
+ 
++	/* Files to check if no longer exist */
++	GHashTable     *check_removed;
++
+ 	/* Status */
+ 	guint           been_started : 1;
+ 	guint           been_crawled : 1;
+@@ -555,6 +558,11 @@ tracker_miner_fs_init (TrackerMinerFS *object)
+ 	                                         (GDestroyNotify) g_object_unref,
+ 	                                         (GDestroyNotify) g_free);
+ 
++	priv->check_removed = g_hash_table_new_full (g_file_hash,
++	                                             (GEqualFunc) g_file_equal,
++	                                             (GDestroyNotify) g_object_unref,
++	                                             NULL);
++
+ 	priv->mtime_checking = TRUE;
+ 	priv->initial_crawling = TRUE;
+ }
+@@ -689,6 +697,10 @@ fs_finalize (GObject *object)
+ 		g_hash_table_unref (priv->iri_cache);
+ 	}
+ 
++	if (priv->check_removed) {
++		g_hash_table_unref (priv->check_removed);
++	}
++
+ 	G_OBJECT_CLASS (tracker_miner_fs_parent_class)->finalize (object);
+ }
+ 
+@@ -1016,17 +1028,24 @@ sparql_update_cb (GObject      *object,
+ 		if (fs->private->current_parent) {
+ 			GFile *parent;
+ 
++			/* Note: parent may be NULL if the file represents
++			 * the root directory of the file system (applies to
++			 * .gvfs mounts also!) */
+ 			parent = g_file_get_parent (data->file);
+ 
+-			if (g_file_equal (parent, fs->private->current_parent) &&
+-			    g_hash_table_lookup (fs->private->iri_cache, data->file) == NULL) {
+-				/* Item is processed, add an empty element for the processed GFile,
+-				 * in case it is again processed before the cache expires
+-				 */
+-				g_hash_table_insert (fs->private->iri_cache, g_object_ref (data->file), NULL);
++			if (parent) {
++				if (g_file_equal (parent, fs->private->current_parent) &&
++				    g_hash_table_lookup (fs->private->iri_cache, data->file) == NULL) {
++					/* Item is processed, add an empty element for the processed GFile,
++					 * in case it is again processed before the cache expires
++					 */
++					g_hash_table_insert (fs->private->iri_cache,
++					                     g_object_ref (data->file),
++					                     NULL);
++				}
++
++				g_object_unref (parent);
+ 			}
+-
+-			g_object_unref (parent);
+ 		}
+ 	}
+ 
+@@ -1192,10 +1211,18 @@ ensure_iri_cache (TrackerMinerFS *fs,
+ 
+ 	g_hash_table_remove_all (fs->private->iri_cache);
+ 
++	/* Note: parent may be NULL if the file represents
++	 * the root directory of the file system (applies to
++	 * .gvfs mounts also!) */
+ 	parent = g_file_get_parent (file);
++
++	if (!parent) {
++		return;
++	}
++
+ 	uri = g_file_get_uri (parent);
+ 
+-	g_debug ("Generating IRI cache for folder: %s", uri);
++	g_debug ("Generating children cache for URI '%s'", uri);
+ 
+ 	query = g_strdup_printf ("SELECT ?url ?u { "
+ 	                         "  ?u nfo:belongsToContainer ?p ; "
+@@ -1473,7 +1500,7 @@ item_remove (TrackerMinerFS *fs,
+ 	         uri);
+ 
+ 	if (!item_query_exists (fs, file, NULL, &mime)) {
+-		g_debug ("  File does not exist anyway (uri:'%s')", uri);
++		g_debug ("  File does not exist anyway (uri '%s')", uri);
+ 		g_free (uri);
+ 		g_free (mime);
+ 		return TRUE;
+@@ -1762,7 +1789,7 @@ item_move (TrackerMinerFS *fs,
+ 	         source_uri,
+ 	         uri);
+ 
+-	tracker_thumbnailer_move_add (source_uri, 
++	tracker_thumbnailer_move_add (source_uri,
+ 	                              g_file_info_get_content_type (file_info),
+ 	                              uri);
+ 
+@@ -2236,6 +2263,55 @@ item_queue_handlers_set_up (TrackerMinerFS *fs)
+ 		                   fs);
+ }
+ 
++static gboolean
++remove_unexisting_file_cb (gpointer key,
++                           gpointer value,
++                           gpointer user_data)
++{
++	TrackerMinerFS *fs = user_data;
++	GFile *file = key;
++
++	/* If file no longer exists, remove it from the store*/
++	if (!g_file_query_exists (file, NULL)) {
++		gchar *uri;
++
++		uri = g_file_get_uri (file);
++		g_debug ("  Marking file which no longer exists in FS for removal: %s", uri);
++		g_free (uri);
++
++		g_queue_push_tail (fs->private->items_deleted,
++		                   g_object_ref (file));
++
++		item_queue_handlers_set_up (fs);
++	}
++
++	return TRUE;
++}
++
++static void
++check_if_files_removed (TrackerMinerFS *fs)
++{
++	g_debug ("Checking if any file was removed...");
++	g_hash_table_foreach_remove (fs->private->check_removed,
++	                             remove_unexisting_file_cb,
++	                             fs);
++}
++
++static void
++add_to_check_removed_cb (gpointer key,
++                         gpointer value,
++                         gpointer user_data)
++{
++	TrackerMinerFS *fs = user_data;
++	GFile *file = key;
++
++	/* Not adding any data to the value, we just want
++	 * fast search for key availability */
++	g_hash_table_insert (fs->private->check_removed,
++	                     g_object_ref (file),
++	                     NULL);
++}
++
+ static void
+ ensure_mtime_cache (TrackerMinerFS *fs,
+                     GFile          *file)
+@@ -2251,10 +2327,14 @@ ensure_mtime_cache (TrackerMinerFS *fs,
+ 		                                                  (GDestroyNotify) g_free);
+ 	}
+ 
++	/* Note: parent may be NULL if the file represents
++	 * the root directory of the file system (applies to
++	 * .gvfs mounts also!) */
+ 	parent = g_file_get_parent (file);
+ 
+ 	if (fs->private->current_parent) {
+-		if (g_file_equal (parent, fs->private->current_parent)) {
++		if (parent &&
++		    g_file_equal (parent, fs->private->current_parent)) {
+ 			/* Cache is still valid */
+ 			g_object_unref (parent);
+ 			return;
+@@ -2267,42 +2347,46 @@ ensure_mtime_cache (TrackerMinerFS *fs,
+ 
+ 	g_hash_table_remove_all (fs->private->mtime_cache);
+ 
+-	uri = g_file_get_uri (parent);
++	/* Initialize data contents */
++	data.main_loop = g_main_loop_new (NULL, FALSE);
++	data.values = g_hash_table_ref (fs->private->mtime_cache);
+ 
+-	g_debug ("Generating mtime cache for folder: %s", uri);
++	if (parent) {
++		uri = g_file_get_uri (parent);
+ 
+-	query = g_strdup_printf ("SELECT ?url ?last { ?u nfo:belongsToContainer ?p ; "
+-	                                                "nie:url ?url ; "
+-	                                                "nfo:fileLastModified ?last . "
+-	                                             "?p nie:url \"%s\" }", uri);
++		g_debug ("Generating mtime cache for URI '%s'", uri);
+ 
+-	g_free (uri);
++		query = g_strdup_printf ("SELECT ?url ?last { ?u nfo:belongsToContainer ?p ; "
++		                                                "nie:url ?url ; "
++		                                                "nfo:fileLastModified ?last . "
++		                                             "?p nie:url \"%s\" }", uri);
+ 
+-	data.main_loop = g_main_loop_new (NULL, FALSE);
+-	data.values = g_hash_table_ref (fs->private->mtime_cache);
++		g_free (uri);
+ 
+-	tracker_miner_execute_sparql (TRACKER_MINER (fs),
+-	                              query,
+-	                              NULL,
+-	                              cache_query_cb,
+-	                              &data);
+-	g_free (query);
++		tracker_miner_execute_sparql (TRACKER_MINER (fs),
++		                              query,
++		                              NULL,
++		                              cache_query_cb,
++		                              &data);
++		g_free (query);
+ 
+-	g_main_loop_run (data.main_loop);
++		g_main_loop_run (data.main_loop);
++	}
+ 
+-	if (g_hash_table_size (data.values) == 0 &&
++	if ((!parent || g_hash_table_size (data.values) == 0) &&
+ 	    file_is_crawl_directory (fs, file)) {
+ 		/* File is a crawl directory itself, query its mtime directly */
+ 		uri = g_file_get_uri (file);
+ 
+-		g_debug ("Folder %s is a crawl directory, generating mtime cache for it", uri);
++		g_debug ("Generating mtime cache for URI '%s' (config location)", uri);
+ 
+ 		query = g_strdup_printf ("SELECT ?url ?last "
+ 		                         "WHERE { "
+ 		                         "  ?u nfo:fileLastModified ?last ; "
+ 		                         "     nie:url ?url ; "
+ 		                         "     nie:url \"%s\" "
+-		                         "}", uri);
++		                         "}",
++					 uri);
+ 		g_free (uri);
+ 
+ 		tracker_miner_execute_sparql (TRACKER_MINER (fs),
+@@ -2317,6 +2401,11 @@ ensure_mtime_cache (TrackerMinerFS *fs,
+ 
+ 	g_main_loop_unref (data.main_loop);
+ 	g_hash_table_unref (data.values);
++
++	/* Iterate repopulated HT and add all to the check_removed HT */
++	g_hash_table_foreach (fs->private->mtime_cache,
++	                      add_to_check_removed_cb,
++	                      fs);
+ }
+ 
+ static gboolean
+@@ -2329,9 +2418,19 @@ should_change_index_for_file (TrackerMinerFS *fs,
+ 	struct tm           t;
+ 	gchar              *time_str, *lookup_time;
+ 
++	/* Make sure mtime cache contains the mtimes of all files in the
++	 * same directory as the given file
++	 */
+ 	ensure_mtime_cache (fs, file);
+-	lookup_time = g_hash_table_lookup (fs->private->mtime_cache, file);
+ 
++	/* Remove the file from the list of files to be checked if removed */
++	g_hash_table_remove (fs->private->check_removed, file);
++
++	/* If the file is NOT found in the cache, it means its a new
++	 * file the store doesn't know about, so just report it to be
++	 * re-indexed.
++	 */
++	lookup_time = g_hash_table_lookup (fs->private->mtime_cache, file);
+ 	if (!lookup_time) {
+ 		return TRUE;
+ 	}
+@@ -2816,6 +2915,9 @@ crawler_finished_cb (TrackerCrawler *crawler,
+ 	directory_data_unref (fs->private->current_directory);
+ 	fs->private->current_directory = NULL;
+ 
++	/* Check if any file was left after whole crawling */
++	check_if_files_removed (fs);
++
+ 	/* Proceed to next thing to process */
+ 	crawl_directories_start (fs);
+ }
+@@ -2958,6 +3060,23 @@ should_recurse_for_directory (TrackerMinerFS *fs,
+ 	return recurse;
+ }
+ 
++
++/* Returns 0 if 'a' and 'b' point to the same diretory, OR if
++ *  'b' is contained inside directory 'a' and 'a' is recursively
++ *  indexed. */
++static gint
++directory_compare_cb (gconstpointer a,
++                      gconstpointer b)
++{
++	DirectoryData *dda = (DirectoryData *) a;
++	DirectoryData *ddb = (DirectoryData *) b;
++
++	return (g_file_equal (dda->file, ddb->file) ||
++	        (dda->recurse &&
++	         g_file_has_prefix (ddb->file, dda->file))) ? 0 : -1;
++}
++
++
+ /* This function is for internal use, adds the file to the processing
+  * queue with the same directory settings than the corresponding
+  * config directory.
+@@ -2972,10 +3091,18 @@ tracker_miner_fs_directory_add_internal (TrackerMinerFS *fs,
+ 	recurse = should_recurse_for_directory (fs, file);
+ 	data = directory_data_new (file, recurse);
+ 
+-	fs->private->directories =
+-		g_list_append (fs->private->directories, data);
++	/* Only add if not already there */
++	if (!g_list_find_custom (fs->private->directories,
++	                         data,
++	                         directory_compare_cb)) {
++		fs->private->directories =
++			g_list_append (fs->private->directories,
++			               directory_data_ref (data));
+ 
+-	crawl_directories_start (fs);
++		crawl_directories_start (fs);
++	}
++
++	directory_data_unref (data);
+ }
+ 
+ /**
+@@ -2998,14 +3125,27 @@ tracker_miner_fs_directory_add (TrackerMinerFS *fs,
+ 
+ 	dir_data = directory_data_new (file, recurse);
+ 
+-	fs->private->config_directories =
+-		g_list_append (fs->private->config_directories, dir_data);
++	/* New directory to add in config_directories? */
++	if (!g_list_find_custom (fs->private->config_directories,
++	                         dir_data,
++	                         directory_compare_cb)) {
++		fs->private->config_directories =
++			g_list_append (fs->private->config_directories,
++			               directory_data_ref (dir_data));
++	}
++
++	/* If not already in the list to process, add it */
++	if (!g_list_find_custom (fs->private->directories,
++	                         dir_data,
++	                         directory_compare_cb)) {
++		fs->private->directories =
++			g_list_append (fs->private->directories,
++			               directory_data_ref (dir_data));
+ 
+-	fs->private->directories =
+-		g_list_append (fs->private->directories,
+-			       directory_data_ref (dir_data));
++		crawl_directories_start (fs);
++	}
+ 
+-	crawl_directories_start (fs);
++	directory_data_unref (dir_data);
+ }
+ 
+ static void
+@@ -3116,6 +3256,9 @@ tracker_miner_fs_directory_remove (TrackerMinerFS *fs,
+ 		pool = pool->next;
+ 	}
+ 
++	/* Remove all monitors */
++	tracker_monitor_remove_recursively (fs->private->monitor, file);
++
+ 	return return_val;
+ }
+ 
+diff --git a/src/libtracker-miner/tracker-miner-object.c b/src/libtracker-miner/tracker-miner-object.c
+index 33827b8..466e54c 100644
+--- a/src/libtracker-miner/tracker-miner-object.c
++++ b/src/libtracker-miner/tracker-miner-object.c
+@@ -440,7 +440,8 @@ store_name_monitor_cb (TrackerMiner *miner,
+ {
+ 	GError *error = NULL;
+ 
+-	g_debug ("Tracker-store availability has changed to %d", available);
++	g_debug ("Store availability has changed to %s", 
++		 available ? "AVAILABLE" : "UNAVAILABLE");
+ 
+ 	if (available && miner->private->availability_cookie != 0) {
+ 		tracker_miner_resume (miner,
+@@ -448,7 +449,7 @@ store_name_monitor_cb (TrackerMiner *miner,
+ 		                      &error);
+ 
+ 		if (error) {
+-			g_warning ("Error happened resuming miner: %s\n", error->message);
++			g_warning ("Error happened resuming miner, %s", error->message);
+ 			g_error_free (error);
+ 		}
+ 
+@@ -461,7 +462,7 @@ store_name_monitor_cb (TrackerMiner *miner,
+ 		                                 &error);
+ 
+ 		if (error) {
+-			g_warning ("Could not pause: %s", error->message);
++			g_warning ("Could not pause, %s", error->message);
+ 			g_error_free (error);
+ 		} else {
+ 			miner->private->availability_cookie = cookie_id;
+diff --git a/src/libtracker-miner/tracker-storage.c b/src/libtracker-miner/tracker-storage.c
+index 90a9b13..9fde62e 100644
+--- a/src/libtracker-miner/tracker-storage.c
++++ b/src/libtracker-miner/tracker-storage.c
+@@ -22,6 +22,7 @@
+ #include <string.h>
+ 
+ #include <gio/gio.h>
++#include <gio/gunixmounts.h>
+ 
+ #include <libtracker-common/tracker-log.h>
+ 
+@@ -70,16 +71,13 @@ static void     tracker_storage_finalize (GObject        *object);
+ static gboolean mount_info_free          (GNode          *node,
+                                           gpointer        user_data);
+ static void     mount_node_free          (GNode          *node);
+-static gboolean drives_setup             (TrackerStorage *storage);
++static gboolean mounts_setup             (TrackerStorage *storage);
+ static void     mount_added_cb           (GVolumeMonitor *monitor,
+                                           GMount         *mount,
+                                           gpointer        user_data);
+ static void     mount_removed_cb         (GVolumeMonitor *monitor,
+                                           GMount         *mount,
+                                           gpointer        user_data);
+-static void     volume_added_cb          (GVolumeMonitor *monitor,
+-                                          GVolume        *volume,
+-                                          gpointer        user_data);
+ 
+ enum {
+ 	MOUNT_POINT_ADDED,
+@@ -154,13 +152,11 @@ tracker_storage_init (TrackerStorage *storage)
+ 	                         G_CALLBACK (mount_removed_cb), storage, 0);
+ 	g_signal_connect_object (priv->volume_monitor, "mount-added",
+ 	                         G_CALLBACK (mount_added_cb), storage, 0);
+-	g_signal_connect_object (priv->volume_monitor, "volume-added",
+-	                         G_CALLBACK (volume_added_cb), storage, 0);
+ 
+-	g_message ("Drive/Volume monitors set up for to watch for added, removed and pre-unmounts...");
++	g_message ("Mount monitors set up for to watch for added, removed and pre-unmounts...");
+ 
+-	/* Get all devices which are mountable and set them up */
+-	if (!drives_setup (storage)) {
++	/* Get all mounts and set them up */
++	if (!mounts_setup (storage)) {
+ 		return;
+ 	}
+ }
+@@ -326,11 +322,11 @@ mount_add_hierarchy (GNode       *root,
+ }
+ 
+ static void
+-mount_add (TrackerStorage *storage,
+-           const gchar    *uuid,
+-           const gchar    *mount_point,
+-           gboolean        removable_device,
+-           gboolean        optical_disc)
++mount_add_new (TrackerStorage *storage,
++               const gchar    *uuid,
++               const gchar    *mount_point,
++               gboolean        removable_device,
++               gboolean        optical_disc)
+ {
+ 	TrackerStoragePrivate *priv;
+ 	GNode *node;
+@@ -340,8 +336,8 @@ mount_add (TrackerStorage *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);
+ 
+-	g_signal_emit (storage, 
+-	               signals[MOUNT_POINT_ADDED], 
++	g_signal_emit (storage,
++	               signals[MOUNT_POINT_ADDED],
+ 	               0,
+ 	               uuid,
+ 	               mount_point,
+@@ -352,240 +348,317 @@ mount_add (TrackerStorage *storage,
+ 
+ static gchar *
+ mount_guess_content_type (GFile    *mount_root,
+-                          gboolean *is_multimedia)
++			  GVolume  *volume,
++			  gboolean *is_optical,
++			  gboolean *is_multimedia)
+ {
++	GUnixMountEntry *entry;
+ 	gchar *content_type = NULL;
++	gchar *mount_path;
++	gchar **guess_type;
++	gint i;
+ 
+-	/* Set defaults */
+-	*is_multimedia = FALSE;
++	/* This function has 2 purposes:
++	 *
++	 * 1. Detect if we are using optical media
++	 * 2. Detect if we are video or music, we can't index those types
++	 */
+ 
+ 	if (g_file_has_uri_scheme (mount_root, "cdda")) {
++		g_debug ("  Scheme is CDDA, assuming this is a CD");
++
++		*is_optical = TRUE;
+ 		*is_multimedia = TRUE;
+ 
+-		content_type = g_strdup ("x-content/audio-cdda");
+-	} 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 */
+-				content_type = g_strdup (guess_type[i]);
+-				break;
+-			} else if (!g_strcmp0 (guess_type[i], "x-content/video-bluray") ||
+-			           !g_strcmp0 (guess_type[i], "x-content/video-dvd") ||
+-			           !g_strcmp0 (guess_type[i], "x-content/video-hddvd") ||
+-			           !g_strcmp0 (guess_type[i], "x-content/video-svcd") ||
+-			           !g_strcmp0 (guess_type[i], "x-content/video-vcd")) {
+-				/* Videos */
+-				*is_multimedia = TRUE;
+-				content_type = g_strdup (guess_type[i]);
+-				break;
+-			} else if (!g_strcmp0 (guess_type[i], "x-content/audio-cdda") ||
+-			           !g_strcmp0 (guess_type[i], "x-content/audio-dvd") ||
+-			           !g_strcmp0 (guess_type[i], "x-content/audio-player")) {
+-				/* Audios */
+-				*is_multimedia = TRUE;
+-				content_type = g_strdup (guess_type[i]);
+-				break;
+-			} else if (!g_strcmp0 (guess_type[i], "x-content/blank-bd") ||
+-			           !g_strcmp0 (guess_type[i], "x-content/blank-cd") ||
+-			           !g_strcmp0 (guess_type[i], "x-content/blank-dvd") ||
+-			           !g_strcmp0 (guess_type[i], "x-content/blank-hddvd")) {
+-				/* Blank */
+-				content_type = g_strdup (guess_type[i]);
+-				break;
+-			} else if (!g_strcmp0 (guess_type[i], "x-content/software") ||
+-			           !g_strcmp0 (guess_type[i], "x-content/unix-software") ||
+-			           !g_strcmp0 (guess_type[i], "x-content/win32-software")) {
+-				/* NOTE: This one is a guess, can we
+-				 * have this content type on
+-				 * none-optical mount points?
+-				 */
+-				content_type = g_strdup (guess_type[i]);
+-				break;
+-			} else if (!content_type) {
+-				content_type = g_strdup (guess_type[i]);
+-				break;
+-			}
+-		}
+-		
+-		if (guess_type) {
+-			g_strfreev (guess_type);
+-		}
++		return g_strdup ("x-content/audio-cdda");
+ 	}
+ 
+-	return content_type;
+-}
++	*is_optical = FALSE;
++	*is_multimedia = FALSE;
+ 
+-static void
+-volume_add (TrackerStorage *storage,
+-            GVolume        *volume,
+-            gboolean        initialization)
+-{
+-	TrackerStoragePrivate *priv;
+-	GMount *mount;
+-	gchar *name;
+-	gboolean is_mounted;
+-	gboolean is_optical;
+-	gchar *uuid;
+-	gchar *mount_point;
+-	gchar *device_file;
++	mount_path = g_file_get_path (mount_root);
++
++	/* FIXME: Try to assume we have a unix mount :(
++	 * EEK, once in a while, I have to write crack, oh well
++	 */
++	entry = g_unix_mount_at (mount_path, NULL);
++
++	if (entry) {
++		const gchar *filesystem_type;
++		gchar *device_path = NULL;
+ 
+-	if (!initialization) {
+-		GDrive *drive;
++		filesystem_type = g_unix_mount_get_fs_type (entry);
++		g_debug ("  Using filesystem type:'%s'",
++			 filesystem_type);
+ 
+-		drive = g_volume_get_drive (volume);
++		/* Volume may be NULL */
++		if (volume) {
++			device_path = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
++			g_debug ("  Using device path:'%s'",
++			         device_path);
++		}
+ 
+-		if (drive) {
+-			g_debug ("Drive:'%s' added 1 volume:",
+-			         g_drive_get_name (drive));
++		/* NOTE: This code was taken from guess_mount_type()
++		 * in GIO's gunixmounts.c and adapted purely for
++		 * guessing optical media. We don't use the guessing
++		 * code for other types such as MEMSTICKS, ZIPs,
++		 * IPODs, etc.
++		 *
++		 * This code may need updating over time since it is
++		 * very situational depending on how distributions
++		 * mount their devices and how devices are named in
++		 * /dev.
++		 */
++		if (strcmp (filesystem_type, "udf") == 0 ||
++		    strcmp (filesystem_type, "iso9660") == 0 ||
++		    strcmp (filesystem_type, "cd9660") == 0 ||
++		    (device_path &&
++		     (g_str_has_prefix (device_path, "/dev/cdrom") ||
++		      g_str_has_prefix (device_path, "/dev/acd") ||
++		      g_str_has_prefix (device_path, "/dev/cd")))) {
++			*is_optical = TRUE;
++		} else if (device_path &&
++		           g_str_has_prefix (device_path, "/vol/")) {
++			const gchar *name;
++
++			name = mount_path + strlen ("/");
++
++			if (g_str_has_prefix (name, "cdrom")) {
++				*is_optical = TRUE;
++			}
+ 		} else {
+-			g_debug ("No drive associated with volume being added:");
++			gchar *basename = g_path_get_basename (mount_path);
++
++			if (g_str_has_prefix (basename, "cdr") ||
++			    g_str_has_prefix (basename, "cdwriter") ||
++			    g_str_has_prefix (basename, "burn") ||
++			    g_str_has_prefix (basename, "dvdr")) {
++				*is_optical = TRUE;
++			}
++
++			g_free (basename);
+ 		}
+-	}
+ 
+-	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");
+-		g_free (name);
+-		return;
++		g_free (device_path);
++		g_free (mount_path);
++	} else {
++		g_debug ("  No GUnixMountEntry found, needed for detecting if optical media... :(");
++		g_free (mount_path);
+ 	}
+ 
+-	uuid = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UUID);
+-	if (!uuid) {
+-		GFile *file;
+-		gchar *content_type;
+-		gboolean is_multimedia;
+-
+-		mount = g_volume_get_mount (volume); 
+-		
+-		if (mount) {
+-			file = g_mount_get_root (mount);
+-			g_object_unref (mount);
+-		} else {
+-			g_debug ("  Being ignored because there is no mount point and no UUID");
+-			g_free (name);
+-			return;
++	/* We try to determine the content type because we don't want
++	 * to store Volume information in Tracker about DVDs and media
++	 * which has no real data for us to mine.
++	 *
++	 * Generally, if is_multimedia is TRUE then we end up ignoring
++	 * the media.
++	 */
++	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 */
++			content_type = g_strdup (guess_type[i]);
++			break;
++		} else if (!g_strcmp0 (guess_type[i], "x-content/video-bluray") ||
++			   !g_strcmp0 (guess_type[i], "x-content/video-dvd") ||
++			   !g_strcmp0 (guess_type[i], "x-content/video-hddvd") ||
++			   !g_strcmp0 (guess_type[i], "x-content/video-svcd") ||
++			   !g_strcmp0 (guess_type[i], "x-content/video-vcd")) {
++			/* Videos */
++			*is_multimedia = TRUE;
++			content_type = g_strdup (guess_type[i]);
++			break;
++		} else if (!g_strcmp0 (guess_type[i], "x-content/audio-cdda") ||
++			   !g_strcmp0 (guess_type[i], "x-content/audio-dvd") ||
++			   !g_strcmp0 (guess_type[i], "x-content/audio-player")) {
++			/* Audios */
++			*is_multimedia = TRUE;
++			content_type = g_strdup (guess_type[i]);
++			break;
++		} else if (!g_strcmp0 (guess_type[i], "x-content/blank-bd") ||
++			   !g_strcmp0 (guess_type[i], "x-content/blank-cd") ||
++			   !g_strcmp0 (guess_type[i], "x-content/blank-dvd") ||
++			   !g_strcmp0 (guess_type[i], "x-content/blank-hddvd")) {
++			/* Blank */
++			content_type = g_strdup (guess_type[i]);
++			break;
++		} else if (!g_strcmp0 (guess_type[i], "x-content/software") ||
++			   !g_strcmp0 (guess_type[i], "x-content/unix-software") ||
++			   !g_strcmp0 (guess_type[i], "x-content/win32-software")) {
++			/* NOTE: This one is a guess, can we
++			 * have this content type on
++			 * none-optical mount points?
++			 */
++			content_type = g_strdup (guess_type[i]);
++			break;
++		} else if (!content_type) {
++			content_type = g_strdup (guess_type[i]);
++			break;
+ 		}
++	}
+ 
+-		content_type = mount_guess_content_type (file, &is_multimedia);
+-		g_object_unref (file);
++	if (guess_type) {
++		g_strfreev (guess_type);
++	}
+ 
+-		g_debug ("  No UUID, guessed content type:'%s', has music/video:%s",
+-		           content_type,
+-		           is_multimedia ? "yes" : "no");
++	return content_type;
++}
+ 
+-		if (!is_multimedia) {
+-			uuid = g_strdup (name);
+-			g_debug ("  Using UUID:'%s' for optical disc", uuid);
+-		}
++static void
++mount_add (TrackerStorage *storage,
++           GMount         *mount)
++{
++	TrackerStoragePrivate *priv;
++	GFile *root;
++	GVolume *volume;
++	gchar *mount_name, *mount_path, *uuid;
++	gboolean is_optical = FALSE;
++	gboolean is_removable = FALSE;
++
++	/* Get mount name */
++	mount_name = g_mount_get_name (mount);
++
++	/* Get root path of the mount */
++	root = g_mount_get_root (mount);
++	mount_path = g_file_get_path (root);
++
++	g_debug ("Found '%s' mounted on path '%s'",
++	         mount_name,
++		 mount_path);
++
++	/* Do not process shadowed mounts! */
++	if (g_mount_is_shadowed (mount)) {
++		g_debug ("  Skipping shadowed mount '%s'", mount_name);
++		g_object_unref (root);
++		g_free (mount_path);
++		g_free (mount_name);
++		return;
++	}
+ 
+-		g_free (content_type);
++	priv = TRACKER_STORAGE_GET_PRIVATE (storage);
++
++	/* fstab partitions may not have corresponding
++	 * GVolumes, so volume may be NULL */
++	volume = g_mount_get_volume (mount);
++	if (volume) {
++		/* GMount with GVolume */
+ 
++		/* Try to get UUID from the Volume.
++		 * Note that g_volume_get_uuid() is NOT equivalent */
++		uuid = g_volume_get_identifier (volume,
++		                                G_VOLUME_IDENTIFIER_KIND_UUID);
+ 		if (!uuid) {
+-			g_debug ("  Being ignored because mount is not optical media or is music/video");
+-			g_free (name);
+-			return;
+-		}
++			gchar *content_type;
++			gboolean is_multimedia;
+ 
+-		is_optical = TRUE;
+-	} else {
+-		/* We assume that all devices that are non-optical
+-		 * have UUIDS already. Since optical devices are the
+-		 * only ones which seem to have no UUID.
+-		 */
+-		is_optical = FALSE;
+-	}
++			/* Optical discs usually won't have UUID in the GVolume */
++			content_type = mount_guess_content_type (root, volume, &is_optical, &is_multimedia);
++			is_removable = TRUE;
+ 
+-	g_free (name);
++			/* We don't index content which is video or music, nothing to index */
++			if (!is_multimedia) {
++				uuid = g_compute_checksum_for_string (G_CHECKSUM_MD5,
++								      mount_name,
++								      -1);
++				g_debug ("  No UUID, generated:'%s' (based on mount name)", uuid);
++				g_debug ("  Assuming GVolume has removable media, if wrong report a bug!");
++			} else {
++				g_debug ("  Being ignored because mount is music/video, content type is '%s'",
++					 content_type);
++			}
++
++			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) */
++			GDrive *drive;
++
++			drive = g_volume_get_drive (volume);
++			if (drive) {
++				is_removable = g_drive_is_media_removable (drive);
++				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;
++			}
++		}
+ 
+-	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); 
+-
+-	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;
++		g_object_unref (volume);
+ 	} else {
+-		mount_point = NULL;
+-		is_mounted = FALSE;
++		/* GMount without GVolume.
++		 * Note: Never found a case where this g_mount_get_uuid() returns
++		 * non-NULL... :-) */
++		uuid = g_mount_get_uuid (mount);
++		if (!uuid) {
++			if (mount_path) {
++				gchar *content_type;
++				gboolean is_multimedia;
++
++				content_type = mount_guess_content_type (root, volume, &is_optical, &is_multimedia);
++
++				if (!is_multimedia) {
++					uuid = g_compute_checksum_for_string (G_CHECKSUM_MD5,
++									      mount_path,
++									      -1);
++					g_debug ("  No UUID, generated:'%s' (based on mount path)", uuid);
++				} else {
++					g_debug ("  Being ignored because mount is music/video, content type is '%s'",
++						 content_type);
++				}
++
++				g_free (content_type);
++			} else {
++				g_debug ("  Being ignored because mount has no GVolume (i.e. not user mountable) "
++				         "and has mount root path available");
++			}
++		}
+ 	}
+-	
+-	g_debug ("    UUID         : %s", uuid);
+-	g_debug ("    Mounted      : %s", is_mounted ? "yes" : "no");
+-
+-	priv = TRACKER_STORAGE_GET_PRIVATE (storage);
+ 
+-	if (mount_point && !g_hash_table_lookup (priv->mounts_by_uuid, uuid)) {
+-		mount_add (storage, uuid, mount_point, TRUE, is_optical);
++	/* If we got something to be used as UUID, then add the mount
++	 * to the TrackerStorage */
++	if (uuid && !g_hash_table_lookup (priv->mounts_by_uuid, uuid)) {
++		g_debug ("  Adding mount point with UUID:'%s', removable: %s, optical: %s",
++		         uuid,
++		         is_removable ? "yes" : "no",
++		         is_optical ? "yes" : "no");
++		mount_add_new (storage, uuid, mount_path, is_removable, is_optical);
+ 	}
+ 
++	g_free (mount_name);
++	g_free (mount_path);
+ 	g_free (uuid);
+-	g_free (mount_point);
+-	g_free (device_file);
++	g_object_unref (root);
+ }
+ 
+ static gboolean
+-drives_setup (TrackerStorage *storage)
++mounts_setup (TrackerStorage *storage)
+ {
+ 	TrackerStoragePrivate *priv;
+-	GList *drives, *ld;
++	GList *mounts, *lm;
+ 
+ 	priv = TRACKER_STORAGE_GET_PRIVATE (storage);
+ 
+-	drives = g_volume_monitor_get_connected_drives (priv->volume_monitor);
++	mounts = g_volume_monitor_get_mounts (priv->volume_monitor);
+ 
+-	if (g_list_length (drives) < 1) {
+-		g_message ("No drives found to iterate");
++	if (!mounts) {
++		g_message ("No mounts found to iterate");
+ 		return TRUE;
+ 	}
+ 
+-	for (ld = drives; ld; ld = ld->next) {
+-		GDrive *drive;
+-		GList *volumes, *lv;
+-		gchar *name;
+-
+-		drive = ld->data;
+-
+-		if (!drive) {
+-			continue;
+-		}
+-		
+-		volumes = g_drive_get_volumes (drive);
+-		name = g_drive_get_name (drive);
+-
+-		g_debug ("Drive:'%s' found with %d %s:",
+-		         name,
+-		         g_list_length (volumes),
+-		         (volumes && !volumes->next) ? "volume" : "volumes");
+-
+-		for (lv = volumes; lv; lv = lv->next) {
+-			volume_add (storage, lv->data, TRUE);
+-			g_object_unref (lv->data);
+-		}
+-
+-		g_list_free (volumes);
+-		g_object_unref (ld->data);
+-		g_free (name);
++	/* Iterate over all available mounts and add them.
++	 * Note that GVolumeMonitor shows only those mounts which are
++	 * actually mounted. */
++	for (lm = mounts; lm; lm = g_list_next (lm)) {
++		mount_add (storage, lm->data);
++		g_object_unref (lm->data);
+ 	}
+ 
+-	g_list_free (drives);
++	g_list_free (mounts);
+ 
+ 	return TRUE;
+ }
+@@ -595,75 +668,7 @@ mount_added_cb (GVolumeMonitor *monitor,
+                 GMount         *mount,
+                 gpointer        user_data)
+ {
+-	TrackerStorage *storage;
+-	GVolume *volume;
+-	GFile *file;
+-	gchar *mount_point;
+-	gchar *name;
+-
+-	storage = user_data;
+-
+-	name = g_mount_get_name (mount);
+-	file = g_mount_get_root (mount);
+-	mount_point = g_file_get_path (file);
+-
+-	g_message ("Mount:'%s', now mounted on:'%s'",
+-	           name,
+-	           mount_point);
+-
+-	volume = g_mount_get_volume (mount);
+-
+-	if (volume) {
+-		gchar *device_file;
+-		gchar *uuid;
+-		gboolean removable_device;
+-
+-		device_file = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
+-		uuid = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UUID);
+-
+-		/* NOTE: We only deal with removable devices */
+-		removable_device = TRUE;
+-
+-		g_message ("  Device:'%s', UUID:'%s'",
+-		           device_file,
+-		           uuid);
+-
+-		/* We don't have a UUID for CDROMs */
+-		if (uuid) {
+-			g_message ("  Being added as a tracker resource to index!");
+-			mount_add (storage, uuid, mount_point, removable_device, FALSE);
+-		} else {
+-			gchar *content_type;
+-			gboolean is_multimedia;
+-
+-			content_type = mount_guess_content_type (file, &is_multimedia);
+-
+-			g_message ("  No UUID, guessed content type:'%s', music/video:%s",
+-			           content_type,
+-			           is_multimedia ? "yes" : "no");
+-
+-			if (!is_multimedia) {
+-				uuid = g_strdup (name);
+-
+-				g_message ("  Using UUID:'%s' for optical disc", uuid);
+-				mount_add (storage, uuid, mount_point, removable_device, TRUE);
+-			} else {
+-				g_message ("  Being ignored because mount is not optical media or is music/video");
+-			}
+-
+-			g_free (content_type);
+-		}
+-
+-		g_free (uuid);
+-		g_free (device_file);
+-		g_object_unref (volume);
+-	} else {
+-		g_message ("  Being ignored because we have no GVolume");
+-	}
+-
+-	g_free (mount_point);
+-	g_object_unref (file);
+-	g_free (name);
++	mount_add (user_data, mount);
+ }
+ 
+ static void
+@@ -700,7 +705,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 {
+@@ -714,14 +719,6 @@ mount_removed_cb (GVolumeMonitor *monitor,
+ 	g_object_unref (file);
+ }
+ 
+-static void
+-volume_added_cb (GVolumeMonitor *monitor,
+-                 GVolume        *volume,
+-                 gpointer        user_data)
+-{
+-	volume_add (user_data, volume, FALSE);
+-}
+-
+ /**
+  * tracker_storage_new:
+  *
+@@ -811,7 +808,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..1c22adc 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);
+@@ -163,7 +164,7 @@ static gboolean    miner_files_ignore_next_update_file  (TrackerMinerFS       *f
+                                                          GCancellable         *cancellable);
+ static void        miner_files_finished                 (TrackerMinerFS       *fs);
+ 
+-static void      extractor_get_embedded_metadata_cancel (GCancellable    *cancellable,
++static void        extractor_get_embedded_metadata_cancel (GCancellable    *cancellable,
+                                                          ProcessFileData *data);
+ 
+ static void        miner_finished_cb                    (TrackerMinerFS *fs,
+@@ -234,13 +235,12 @@ tracker_miner_files_init (TrackerMinerFiles *mf)
+ 	g_signal_connect (priv->power, "notify::on-battery",
+ 	                  G_CALLBACK (battery_status_cb),
+ 	                  mf);
++#endif /* defined(HAVE_UPOWER) || defined(HAVE_HAL) */
+ 
+ 	priv->finished_handler = g_signal_connect_after (mf, "finished",
+ 							 G_CALLBACK (miner_finished_cb),
+ 							 NULL);
+ 
+-#endif /* defined(HAVE_UPOWER) || defined(HAVE_HAL) */
+-
+ 	priv->volume_monitor = g_volume_monitor_get ();
+ 	g_signal_connect (priv->volume_monitor, "mount-pre-unmount",
+ 	                  G_CALLBACK (mount_pre_unmount_cb),
+@@ -548,15 +548,16 @@ set_up_mount_point_cb (GObject      *source,
+                        gpointer      user_data)
+ {
+ 	gchar *removable_device_urn = user_data;
+-
+ 	GError *error = NULL;
++
+ 	tracker_miner_execute_update_finish (TRACKER_MINER (source),
+ 	                                     result,
+ 	                                     &error);
+ 
+ 	if (error) {
+-		g_critical ("Could not set up mount point '%s': %s",
+-		            removable_device_urn, error->message);
++		g_critical ("Could not set mount point in database '%s', %s",
++		            removable_device_urn,
++			    error->message);
+ 		g_error_free (error);
+ 	}
+ 
+@@ -572,8 +573,7 @@ set_up_mount_point (TrackerMinerFiles *miner,
+ {
+ 	GString *queries;
+ 
+-	g_debug ("Setting mount point '%s' state in database (URN '%s')",
+-	         mount_point,
++	g_debug ("Mount point state being set in DB for URN '%s'",
+ 	         removable_device_urn);
+ 
+ 	queries = g_string_new (NULL);
+@@ -769,18 +769,33 @@ query_mount_points_cb (GObject      *source,
+ 
+ 			if (urn) {
+ 				if (mount_point) {
+-					g_debug ("URN '%s' (mount point: %s) was not reported to be mounted, but now it is, updating state",
+-					         urn, mount_point);
++					g_debug ("Mount point state incorrect in DB for URN '%s', "
++						 "currently it is mounted on '%s'",
++					         urn,
++						 mount_point);
+ 				} else {
+-					g_debug ("URN '%s' was not reported to be mounted, but now it is, updating state", urn);
++					g_debug ("Mount point state incorrect in DB for URN '%s', "
++						 "currently it is mounted",
++					         urn);
+ 				}
+-				set_up_mount_point (TRACKER_MINER_FILES (miner), urn, mount_point, TRUE, accumulator);
++
++				set_up_mount_point (TRACKER_MINER_FILES (miner),
++						    urn,
++						    mount_point,
++						    TRUE,
++						    accumulator);
+ 			}
+ 		} else if (!(state & VOLUME_MOUNTED) &&
+ 		           (state & VOLUME_MOUNTED_IN_STORE)) {
+ 			if (urn) {
+-				g_debug ("URN '%s' was reported to be mounted, but it isn't anymore, updating state", urn);
+-				set_up_mount_point (TRACKER_MINER_FILES (miner), urn, NULL, FALSE, accumulator);
++				g_debug ("Mount pont state incorrect in DB for URN '%s', "
++					 "currently it is NOT mounted",
++					 urn);
++				set_up_mount_point (TRACKER_MINER_FILES (miner),
++						    urn,
++						    NULL,
++						    FALSE,
++						    accumulator);
+ 			}
+ 		}
+ 	}
+@@ -818,13 +833,22 @@ mount_point_removed_cb (TrackerStorage *storage,
+ {
+ 	TrackerMinerFiles *miner = user_data;
+ 	gchar *urn;
+-
+-	g_debug ("Removing mount point '%s'", mount_point);
++	GFile *mount_point_file;
+ 
+ 	urn = g_strdup_printf (TRACKER_DATASOURCE_URN_PREFIX "%s", uuid);
++	g_debug ("Mount point removed for URN '%s'", urn);
++
++	mount_point_file = g_file_new_for_path (mount_point);
+ 
++	/* Set mount point status in tracker-store */
+ 	set_up_mount_point (miner, urn, mount_point, FALSE, NULL);
++
++	/* Tell TrackerMinerFS to skip monitoring everything under the mount
++	 *  point (in case there was no pre-unmount notification) */
++	tracker_miner_fs_directory_remove (TRACKER_MINER_FS (miner), mount_point_file);
++
+ 	g_free (urn);
++	g_object_unref (mount_point_file);
+ }
+ 
+ static void
+@@ -837,33 +861,84 @@ mount_point_added_cb (TrackerStorage *storage,
+ {
+ 	TrackerMinerFiles *miner = user_data;
+ 	TrackerMinerFilesPrivate *priv;
+-	GFile *file;
+ 	gchar *urn;
+ 	gboolean index_removable_devices;
+ 	gboolean index_optical_discs;
+-	gboolean should_crawl;
+ 
+ 	priv = TRACKER_MINER_FILES_GET_PRIVATE (miner);
+ 
+ 	index_removable_devices = tracker_config_get_index_removable_devices (priv->config);
+ 	index_optical_discs = tracker_config_get_index_optical_discs (priv->config);
+ 
+-	g_message ("Added mount point '%s'", mount_point);
+-
+-	should_crawl = TRUE;
++	urn = g_strdup_printf (TRACKER_DATASOURCE_URN_PREFIX "%s", uuid);
++	g_message ("Mount point added for URN '%s'", urn);
+ 
+-	if (removable && !tracker_config_get_index_removable_devices (priv->config)) {
++	if (removable && !index_removable_devices) {
+ 		g_message ("  Not crawling, removable devices disabled in config");
+-		should_crawl = FALSE;
+-	}
+-
+-	if (optical && !tracker_config_get_index_optical_discs (priv->config)) {
++	} else if (optical && !index_optical_discs) {
+ 		g_message ("  Not crawling, optical devices discs disabled in config");
+-		should_crawl = FALSE;
+-	}
++	} else if (!removable && !optical) {
++		GFile *mount_point_file;
++		GSList *l;
++
++		mount_point_file = g_file_new_for_path (mount_point);
++
++		/* Check if one of the recursively indexed locations is in
++		 *   the mounted path, or if the mounted path is inside
++		 *   a recursively indexed directory... */
++		for (l = tracker_config_get_index_recursive_directories (miner->private->config);
++		     l;
++		     l = g_slist_next (l)) {
++			GFile *config_file;
++
++			config_file = g_file_new_for_path (l->data);
++
++			if (g_file_equal (config_file, mount_point_file) ||
++			    g_file_has_prefix (config_file, mount_point_file)) {
++				/* If the config path is contained inside the mount path,
++				 *  then add the config path to re-check */
++				g_message ("  Re-check of configured path '%s' needed (recursively)",
++				           (gchar *) l->data);
++				tracker_miner_fs_directory_add (TRACKER_MINER_FS (user_data),
++				                                config_file,
++				                                TRUE);
++			} else if (g_file_has_prefix (mount_point_file, config_file)) {
++				/* If the mount path is contained inside the config path,
++				 *  then add the mount path to re-check */
++				g_message ("  Re-check of path '%s' needed (inside configured path '%s')",
++				           mount_point,
++				           (gchar *) l->data);
++				tracker_miner_fs_directory_add (TRACKER_MINER_FS (user_data),
++				                                mount_point_file,
++				                                TRUE);
++			}
++			g_object_unref (config_file);
++		}
++
++		/* Check if one of the non-recursively indexed locations is in
++		 *  the mount path... */
++		for (l = tracker_config_get_index_single_directories (miner->private->config);
++		     l;
++		     l = g_slist_next (l)) {
++			GFile *config_file;
++
++			config_file = g_file_new_for_path (l->data);
++			if (g_file_equal (config_file, mount_point_file) ||
++			    g_file_has_prefix (config_file, mount_point_file)) {
++				g_message ("  Re-check of configured path '%s' needed (non-recursively)",
++				           (gchar *) l->data);
++				tracker_miner_fs_directory_add (TRACKER_MINER_FS (user_data),
++				                                config_file,
++				                                FALSE);
++			}
++			g_object_unref (config_file);
++		}
+ 
+-	if (should_crawl) {
+-		g_message ("  Adding directory to crawler's queue");
++		g_object_unref (mount_point_file);
++	} else {
++		GFile *file;
++
++		g_message ("  Adding directories in removable/optical media to crawler's queue");
+ 
+ 		file = g_file_new_for_path (mount_point);
+ 		g_object_set_qdata_full (G_OBJECT (file),
+@@ -881,7 +956,6 @@ mount_point_added_cb (TrackerStorage *storage,
+ 		g_object_unref (file);
+ 	}
+ 
+-	urn = g_strdup_printf (TRACKER_DATASOURCE_URN_PREFIX "%s", uuid);
+ 	set_up_mount_point (miner, urn, mount_point, TRUE, NULL);
+ 	g_free (urn);
+ }
+@@ -1014,7 +1088,9 @@ miner_finished_cb (TrackerMinerFS *fs,
+ 		mf->private->finished_handler = 0;
+ 	}
+ 
++#if defined(HAVE_UPOWER) || defined(HAVE_HAL)
+ 	check_battery_status (mf);
++#endif /* defined(HAVE_UPOWER) || defined(HAVE_HAL) */
+ }
+ 
+ #endif /* defined(HAVE_UPOWER) || defined(HAVE_HAL) */
+@@ -1025,10 +1101,14 @@ mount_pre_unmount_cb (GVolumeMonitor    *volume_monitor,
+                       TrackerMinerFiles *mf)
+ {
+ 	GFile *mount_root;
++	gchar *uri;
+ 
+ 	mount_root = g_mount_get_root (mount);
++	uri = g_file_get_uri (mount_root);
++	g_message ("Pre-unmount requested for '%s'", uri);
+ 	tracker_miner_fs_directory_remove (TRACKER_MINER_FS (mf), mount_root);
+ 	g_object_unref (mount_root);
++	g_free (uri);
+ }
+ 
+ static gboolean
+@@ -1795,7 +1875,7 @@ should_check_mtime (TrackerConfig *config)
+ 			g_message ("  No previous timestamp, crawling forced");
+ 			return TRUE;
+ 		}
+-	
++
+ 		now = (guint64) time (NULL);
+ 
+ 		if (now < then + (crawling_interval * SECONDS_PER_DAY)) {



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