tracker r1663 - in branches/xesam-support: . src/libtracker-common src/tracker-indexer src/trackerd



Author: pvanhoof
Date: Thu Jun 12 15:45:56 2008
New Revision: 1663
URL: http://svn.gnome.org/viewvc/tracker?rev=1663&view=rev

Log:
2008-06-12  Philip Van Hoof  <pvanhoof gnome org>

        * svn merge -r 1658:1662 ../indexer-split



Modified:
   branches/xesam-support/ChangeLog
   branches/xesam-support/src/libtracker-common/tracker-dbus.c
   branches/xesam-support/src/libtracker-common/tracker-dbus.h
   branches/xesam-support/src/tracker-indexer/tracker-indexer.c
   branches/xesam-support/src/trackerd/tracker-crawler.c
   branches/xesam-support/src/trackerd/tracker-main.c
   branches/xesam-support/src/trackerd/tracker-monitor.c
   branches/xesam-support/src/trackerd/tracker-monitor.h

Modified: branches/xesam-support/src/libtracker-common/tracker-dbus.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-dbus.c	(original)
+++ branches/xesam-support/src/libtracker-common/tracker-dbus.c	Thu Jun 12 15:45:56 2008
@@ -79,6 +79,44 @@
 	return strv;
 }
 
+gchar **
+tracker_dbus_async_queue_to_strv (GAsyncQueue *queue, 
+				  gint         max)
+{
+	gchar **strv;
+	gint    i = 0;
+	gint    length;
+
+	length = g_async_queue_length (queue);
+		
+	if (max > 0) {
+		length = MIN (max, length);
+	}
+
+	strv = g_new0 (gchar*, length + 1);
+	
+	while (i <= length) {
+		GTimeVal  t;
+		gchar    *str;
+		
+		g_get_current_time (&t);
+		g_time_val_add (&t, 100000);
+
+		/* Get next item and wait 0.1 seconds max per try */
+		str = g_async_queue_timed_pop (queue, &t);
+		if (str) {
+			strv[i++] = str;
+		} else {
+			/* We don't expect this */
+			break;
+		}
+	}
+
+        strv[i] = NULL;
+
+	return strv;
+}
+
 guint
 tracker_dbus_get_next_request_id (void)
 {

Modified: branches/xesam-support/src/libtracker-common/tracker-dbus.h
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-dbus.h	(original)
+++ branches/xesam-support/src/libtracker-common/tracker-dbus.h	Thu Jun 12 15:45:56 2008
@@ -83,6 +83,8 @@
 GValue *         tracker_dbus_g_value_slice_new   (GType            type);
 void             tracker_dbus_g_value_slice_free  (GValue          *value);
 gchar **         tracker_dbus_slist_to_strv       (GSList          *list);
+gchar **         tracker_dbus_async_queue_to_strv (GAsyncQueue     *queue, 
+						   gint             max);
 
 /* Requests */
 guint            tracker_dbus_get_next_request_id (void);

Modified: branches/xesam-support/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-indexer.c	(original)
+++ branches/xesam-support/src/tracker-indexer/tracker-indexer.c	Thu Jun 12 15:45:56 2008
@@ -310,8 +310,8 @@
 
 	priv->module_names = tracker_config_get_index_modules (priv->config);
 
-	priv->indexer_modules = g_hash_table_new_full (g_direct_hash,
-						       g_direct_equal,
+	priv->indexer_modules = g_hash_table_new_full (g_str_hash,
+						       g_str_equal,
 						       NULL,
 						       (GDestroyNotify) g_module_close);
 
@@ -549,9 +549,11 @@
 
 		info = path_info_new (module, dirs[i]);
 		tracker_indexer_add_directory (indexer, info);
+
+		g_free (dirs[i]);
 	}
 
-	g_strfreev (dirs);
+	g_free (dirs);
 }
 
 
@@ -670,19 +672,38 @@
 			       GStrv            files,
 			       GError         **error)
 {
-	/* TrackerIndexerPrivate *priv; */
+	TrackerIndexerPrivate *priv;
+	GModule               *module;
 	guint                  request_id;
-
-	request_id = tracker_dbus_get_next_request_id ();
+	gint                   i;
 
 	tracker_dbus_return_val_if_fail (TRACKER_IS_INDEXER (indexer), FALSE, error);
 	tracker_dbus_return_val_if_fail (files != NULL, FALSE, error);
 
+	priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
+	request_id = tracker_dbus_get_next_request_id ();
+
 	tracker_dbus_request_new (request_id,
                                   "DBus request to process %d files",
 				  g_strv_length (files));
 
-	/* Do work */
+	/* Assume we're using always the files module, bail out if it's not available */
+	module = g_hash_table_lookup (priv->indexer_modules, "files");
+
+	if (!module) {
+		tracker_dbus_request_failed (request_id,
+					     error,
+					     "The files module is not loaded");
+		return FALSE;
+	}
+
+	/* Add files to the queue */
+	for (i = 0; files[i]; i++) {
+		PathInfo *info;
+
+		info = path_info_new (module, files[i]);
+		tracker_indexer_add_file (indexer, info);
+	}
 
 	tracker_dbus_request_success (request_id);
 

Modified: branches/xesam-support/src/trackerd/tracker-crawler.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-crawler.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-crawler.c	Thu Jun 12 15:45:56 2008
@@ -25,6 +25,7 @@
 #include <gio/gio.h>
 
 #include <libtracker-common/tracker-utils.h>
+#include <libtracker-common/tracker-dbus.h>
 
 #include "tracker-crawler.h"
 #include "tracker-dbus.h"
@@ -196,11 +197,21 @@
 crawler_finalize (GObject *object)
 {
 	TrackerCrawlerPriv *priv;
+	gint                i;
 	
 	priv = GET_PRIV (object);
 
-	g_strfreev (priv->ignored_prefixes);
-	g_strfreev (priv->ignored_suffixes);
+	for (i = 0; priv->ignored_prefixes[i] != NULL; i++) {
+		g_free (priv->ignored_prefixes[i]);
+	}
+
+	g_free (priv->ignored_prefixes);
+
+	for (i = 0; priv->ignored_suffixes[i] != NULL; i++) {
+		g_free (priv->ignored_suffixes[i]);
+	}
+
+	g_free (priv->ignored_suffixes);
 
 	g_hash_table_unref (priv->temp_black_list); 
 	g_hash_table_unref (priv->ignored_names); 
@@ -721,12 +732,15 @@
 {
 	TrackerCrawler *crawler;
 	DBusGProxy     *proxy;
-	GPtrArray      *ptr_array;
 	GError         *error;
 	gchar **        files;
 	gboolean        running;
 	gint            length;
+#if 0
 	gint            items;
+	GPtrArray      *ptr_array;
+	gint            i;
+#endif
 
 	crawler = user_data;
 
@@ -751,39 +765,14 @@
 	}
 
 	g_debug ("Processing file queue...");
-        ptr_array = g_ptr_array_new ();
+	files = tracker_dbus_async_queue_to_strv (crawler->priv->files,
+						  FILES_QUEUE_PROCESS_MAX);
 
-	/* Throttle files we send over to the indexer */
-	items = MIN (FILES_QUEUE_PROCESS_MAX, length);
-	g_debug ("Processing %d/%d items in the queue", 
-		 items,
-		 length);
-
-	while (items > 0) {
-		GTimeVal  t;
-		gchar    *filename;
-		
-		g_get_current_time (&t);
-		g_time_val_add (&t, 100000);
-
-		/* Get next filename and wait 0.1 seconds max per try */
-		filename = g_async_queue_timed_pop (crawler->priv->files, &t);
-		if (filename) {
-			g_ptr_array_add (ptr_array, filename);
-			items--;
-		}
-	}
+	g_debug ("Sending %d files to indexer to process", g_strv_length (files));
+	//org_freedesktop_Tracker_Indexer_process_files (proxy, 
+	//					       (const gchar **) files,
+	//					       &error);
 
-	g_ptr_array_add (ptr_array, NULL);
-	files = (gchar **) g_ptr_array_free (ptr_array, FALSE);
-
-	g_debug ("Sending %d files to indexer to process", 
-		 g_strv_length (files));
-
-	org_freedesktop_Tracker_Indexer_process_files (proxy, 
-						       (const gchar **) files,
-						       &error);
-	
 	if (error) {
 		g_critical ("Could not send %d files to indexer to process, %s", 
 			    g_strv_length (files),
@@ -794,7 +783,7 @@
 	}
 
 	g_strfreev (files);
-							     
+
 	return TRUE;
 }
 

Modified: branches/xesam-support/src/trackerd/tracker-main.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-main.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-main.c	Thu Jun 12 15:45:56 2008
@@ -816,12 +816,12 @@
 		return EXIT_FAILURE;
 	}
 
-	sanity_check_option_values ();
-
-	if (!tracker_monitor_init ()) {
+	if (!tracker_monitor_init (tracker->config)) {
 		return EXIT_FAILURE;
 	} 
 
+	sanity_check_option_values ();
+
 	initialise_directories (&need_index);
 
 	tracker_nfs_lock_init (tracker_config_get_nfs_locking (tracker->config));

Modified: branches/xesam-support/src/trackerd/tracker-monitor.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-monitor.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-monitor.c	Thu Jun 12 15:45:56 2008
@@ -31,77 +31,40 @@
  */
 #define MAX_MONITORS (guint) ((2 ^ 13) - 500)   
 
-static GHashTable *monitors;
-
-#if 0
-static void
-get_monitor_roots (GSList **included,
-		   GSList **excluded)
-{
-        GSList *watch_directory_roots;
-        GSList *no_watch_directory_roots;
-        GSList *mounted_directory_roots;
-        GSList *removable_device_roots;
-
-        *included = NULL;
-        *excluded = NULL;
-
-        get_remote_roots (&mounted_directory_roots, 
-			  &removable_device_roots);        
-        
-        /* Delete all stuff in the no watch dirs */
-        watch_directory_roots = 
-                tracker_config_get_watch_directory_roots (config);
-        
-        no_watch_directory_roots = 
-                tracker_config_get_no_watch_directory_roots (config);
-
-        /* Create list for enabled roots based on config */
-        *included = g_slist_concat (*included, g_slist_copy (watch_directory_roots));
-        
-        /* Create list for disabled roots based on config */
-        *excluded = g_slist_concat (*excluded, g_slist_copy (no_watch_directory_roots));
-
-        /* Add or remove roots which pertain to removable media */
-        if (tracker_config_get_index_removable_devices (config)) {
-                *included = g_slist_concat (*included, g_slist_copy (removable_device_roots));
-        } else {
-                *excluded = g_slist_concat (*excluded, g_slist_copy (removable_device_roots));
-        }
-
-        /* Add or remove roots which pertain to mounted directories */
-        if (tracker_config_get_index_mounted_directories (config)) {
-                *included = g_slist_concat (*included, g_slist_copy (mounted_directory_roots));
-        } else {
-                *excluded = g_slist_concat (*excluded, g_slist_copy (mounted_directory_roots));
-        }
-}
-
-#endif
+static GHashTable    *monitors;
+static TrackerConfig *config;
 
 gboolean 
-tracker_monitor_init (void) 
+tracker_monitor_init (TrackerConfig *_config) 
 {
-	if (monitors) {
-		return TRUE;
+	g_return_val_if_fail (TRACKER_IS_CONFIG (_config), FALSE);
+	
+	if (!config) {
+		config = g_object_ref (_config);
+	}
+	
+	if (!monitors) {
+		monitors = g_hash_table_new_full (g_str_hash,
+						  g_str_equal,
+						  g_free,
+						  (GDestroyNotify) g_file_monitor_cancel);
 	}
 
-	monitors = g_hash_table_new_full (g_str_hash,
-					  g_str_equal,
-					  g_free,
-					  (GDestroyNotify) g_file_monitor_cancel);
 	return TRUE;
 }
 
 void
 tracker_monitor_shutdown (void)
 {
-	if (!monitors) {
-		return;
+	if (monitors) {
+		g_hash_table_unref (monitors);
+		monitors = NULL;
+	}
+	
+	if (config) {
+		g_object_unref (config);
+		config = NULL;
 	}
-
-	g_hash_table_unref (monitors);
-	monitors = NULL;
 }
 
 gboolean

Modified: branches/xesam-support/src/trackerd/tracker-monitor.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-monitor.h	(original)
+++ branches/xesam-support/src/trackerd/tracker-monitor.h	Thu Jun 12 15:45:56 2008
@@ -22,16 +22,18 @@
 #ifndef __TRACKERD_MONITOR_H__
 #define __TRACKERD_MONITOR_H__
 
+#include <libtracker-common/tracker-config.h>
+
 #include "tracker-db.h"
 
 G_BEGIN_DECLS
 
-gboolean tracker_monitor_init       (void);
+gboolean tracker_monitor_init       (TrackerConfig *config);
 void     tracker_monitor_shutdown   (void);
-gboolean tracker_monitor_add        (const gchar *path);
-gboolean tracker_monitor_remove     (const gchar *path,
-				     gboolean     delete_subdirs);
-gboolean tracker_monitor_is_watched (const gchar *path);
+gboolean tracker_monitor_add        (const gchar   *path);
+gboolean tracker_monitor_remove     (const gchar   *path,
+				     gboolean       delete_subdirs);
+gboolean tracker_monitor_is_watched (const gchar   *path);
 gint     tracker_monitor_get_count  (void);
 
 G_END_DECLS



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