tracker r1717 - in branches/indexer-split: . data/dbus src/libtracker-db src/tracker-indexer src/trackerd



Author: mr
Date: Thu Jun 19 17:06:28 2008
New Revision: 1717
URL: http://svn.gnome.org/viewvc/tracker?rev=1717&view=rev

Log:
	* src/tracker-indexer/tracker-metadata.c:
	* src/tracker-indexer/tracker-main.c: 
	* src/trackerd/tracker-main.c: DON'T use PID, since it is shared
	between the indexer and the daemon. 

	* src/trackerd/tracker-main.c: Added a call to the blocking
	version of the DBus API to check the database state from the
	indexer so we make sure the indexer ALWAYS creates the database if
	it doesn't exist in the first place. Plus if we force a reindex on
	start up, the indexer is the one that does it. Also, when creating
	the system temporary directory, 

	* src/trackerd/tracker-crawler.c: 
	* src/trackerd/tracker-monitor.c: Updated to renamed API.

	* data/dbus/tracker-indexer.xml:
	* src/tracker-indexer/tracker-indexer.[ch]: Renamed some API calls
	and also added a call to check the database state and return if it
	is the first time it will be indexed. Plus the user can force a
	reindex while checking. This is meant to be called from the daemon
	on start up to make sure the database is ready to use.


Modified:
   branches/indexer-split/ChangeLog
   branches/indexer-split/data/dbus/tracker-indexer.xml
   branches/indexer-split/src/libtracker-db/tracker-db-manager.c
   branches/indexer-split/src/libtracker-db/tracker-db-manager.h
   branches/indexer-split/src/tracker-indexer/tracker-indexer.c
   branches/indexer-split/src/tracker-indexer/tracker-indexer.h
   branches/indexer-split/src/tracker-indexer/tracker-main.c
   branches/indexer-split/src/tracker-indexer/tracker-metadata.c
   branches/indexer-split/src/trackerd/tracker-crawler.c
   branches/indexer-split/src/trackerd/tracker-dbus.c
   branches/indexer-split/src/trackerd/tracker-dbus.h
   branches/indexer-split/src/trackerd/tracker-main.c
   branches/indexer-split/src/trackerd/tracker-monitor.c

Modified: branches/indexer-split/data/dbus/tracker-indexer.xml
==============================================================================
--- branches/indexer-split/data/dbus/tracker-indexer.xml	(original)
+++ branches/indexer-split/data/dbus/tracker-indexer.xml	Thu Jun 19 17:06:28 2008
@@ -10,22 +10,29 @@
 
 <node name="/">
   <interface name="org.freedesktop.Tracker.Indexer">  
+    <method name="DatabaseCheck">
+      <arg type="b" name="force_reindex" direction="in" />
+      <arg type="b" name="first_time_index" direction="out" />
+    </method>
+
+    <method name="DatabaseReindex"/>
+
     <method name="GetRunning">
       <arg type="b" name="is_running" direction="out" />
     </method>
     <method name="SetRunning">
       <arg type="b" name="should_be_running" direction="in" />
     </method>
-    <method name="CheckFiles">
+
+    <method name="FilesCheck">
       <arg type="as" name="files" direction="in" />
     </method>
-    <method name="UpdateFiles">
+    <method name="FilesUpdate">
       <arg type="as" name="files" direction="in" />
     </method>
-    <method name="DeleteFiles">
+    <method name="FilesDelete">
       <arg type="as" name="files" direction="in" />
     </method>
-    <method name="Reindex"/>
     
     <!-- The old signal in the daemon used to send the time taken, we
 	 can add this later

Modified: branches/indexer-split/src/libtracker-db/tracker-db-manager.c
==============================================================================
--- branches/indexer-split/src/libtracker-db/tracker-db-manager.c	(original)
+++ branches/indexer-split/src/libtracker-db/tracker-db-manager.c	Thu Jun 19 17:06:28 2008
@@ -2179,7 +2179,13 @@
 	db_user_data_dir = g_strdup (user_data_dir);
 	db_sys_tmp_dir = g_strdup (sys_tmp_dir);
 
-	/* create directory in tmp */
+	/* Make sure we remove and recreate the cache directory in tmp
+	 * each time we start up, this is meant to be a per-instance
+	 * thing.
+	 */
+	g_message ("Removing directory:'%s'", db_sys_tmp_dir);
+	tracker_path_remove (db_sys_tmp_dir);
+
 	g_message ("Creating directory:'%s'", db_sys_tmp_dir);
 	g_mkdir_with_parents (db_sys_tmp_dir, 00755);
 
@@ -2191,6 +2197,9 @@
 
 	load_prepared_queries ();
 
+	/* Needs to be BEFORE the set_up_databases, since it uses
+	 * public API calls which check we are initialized.
+	 */
 	initialized = TRUE;
 
 	/* Configure database locations and interfaces */
@@ -2270,18 +2279,9 @@
 }
 
 void
-tracker_db_manager_set_up_databases (gboolean remove_all_first) 
+tracker_db_manager_close_all (void)
 {
-	gboolean current_attach_all;
-	guint    i;
-
-	g_return_if_fail (initialized != FALSE);
-
-	/* Save the current attach setting */
-	current_attach_all = attach_all;
-
-	/* Don't attach while we do this... */
-	attach_all = FALSE;
+	guint i;
 
 	/* Close all dbs first. */
         for (i = 0; i < G_N_ELEMENTS (dbs); i++) {
@@ -2290,19 +2290,43 @@
 			dbs[i].iface = NULL;
 		}
         }
+}
 
-	/* Clean up any ontology information we have */
-	tracker_ontology_shutdown ();
+void
+tracker_db_manager_delete_all (void)
+{
+	/* Make sure all DBs are closed first */
+	tracker_db_manager_close_all ();
+
+	/* Physically remove directories */
+	g_message ("Removing directory:'%s'", db_data_dir);
+	tracker_path_remove (db_data_dir);
 	
-	if (remove_all_first) {
-		g_message ("Removing directory:'%s'", db_data_dir);
-		tracker_path_remove (db_data_dir);
+	g_message ("Removing directory:'%s'", db_user_data_dir);
+	tracker_path_remove (db_user_data_dir);
+	
+	g_message ("Removing directory:'%s'", db_sys_tmp_dir);
+	tracker_path_remove (db_sys_tmp_dir);
+}
+
+void
+tracker_db_manager_create_all (gboolean remove_all_first) 
+{
+	gboolean current_attach_all;
+
+	g_return_if_fail (initialized != FALSE);
+
+	/* Save the current attach setting */
+	current_attach_all = attach_all;
 
-		g_message ("Removing directory:'%s'", db_user_data_dir);
-		tracker_path_remove (db_user_data_dir);
+	/* Don't attach while we do this... */
+	attach_all = FALSE;
 
-		g_message ("Removing directory:'%s'", db_sys_tmp_dir);
-		tracker_path_remove (db_sys_tmp_dir);
+	/* Shut things down first */
+	if (remove_all_first) {
+		tracker_db_manager_delete_all ();
+	} else {
+		tracker_db_manager_close_all ();
 	}
 
 	/* Don't check for these first, just do it */
@@ -2315,25 +2339,14 @@
 	g_message ("Creating directory:'%s'", db_sys_tmp_dir);
 	g_mkdir_with_parents (db_sys_tmp_dir, 00755);
 
-	/* Initialize ontology information */
+	/* Reinitialize ontology */
+	tracker_ontology_shutdown ();
 	tracker_ontology_init ();
 
-	/* Create all interfaces (and dbs as a result) and then unref
-	 * them to close the dbs.
+	/* Now we close these databases again and wait for the next
+	 * time they are needed.
 	 */
-        for (i = 0; i < G_N_ELEMENTS (dbs); i++) {
-		tracker_db_manager_get_db_interface (i);
-
-		if (dbs[i].iface) {
-			g_object_unref (dbs[i].iface);
-
-
-			/* Reset the interface value so we get a new
-			 * object next time it is needed.
-			 */
-			dbs[i].iface = NULL;
-		}
-        }
+	tracker_db_manager_close_all ();
 
 	/* Set the attach setting back to what it was */
 	attach_all = current_attach_all;

Modified: branches/indexer-split/src/libtracker-db/tracker-db-manager.h
==============================================================================
--- branches/indexer-split/src/libtracker-db/tracker-db-manager.h	(original)
+++ branches/indexer-split/src/libtracker-db/tracker-db-manager.h	Thu Jun 19 17:06:28 2008
@@ -49,9 +49,12 @@
 							     const gchar        *user_data_dir,
 							     const gchar        *sys_tmp_root_dir);
 void         tracker_db_manager_shutdown                    (void);
+
 gboolean     tracker_db_manager_need_reindex                (void);
+void         tracker_db_manager_close_all                   (void);
+void         tracker_db_manager_delete_all                  (void);
+void         tracker_db_manager_create_all                  (gboolean            remove_all_first);
 
-void         tracker_db_manager_set_up_databases            (gboolean            remove_all_first);
 const gchar *tracker_db_manager_get_file                    (TrackerDB           db);
 TrackerDBInterface *
              tracker_db_manager_get_db_interface            (TrackerDB           db);

Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer.c	(original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer.c	Thu Jun 19 17:06:28 2008
@@ -88,7 +88,7 @@
 
 	guint idle_id;
 
-	guint reindex : 1;
+	gboolean reindexed_on_init;
 };
 
 struct PathInfo {
@@ -154,7 +154,7 @@
 	priv->contents = NULL;
 	
 	/* Now create the new databases */
-	tracker_db_manager_set_up_databases (TRUE);
+	tracker_db_manager_create_all (TRUE);
 
 	/* Now establish new connections */
 	priv->common = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON);
@@ -306,6 +306,12 @@
 	
 	if (tracker_db_manager_need_reindex ()) {
 		reindex_database (indexer);
+
+		/* We set this flag so we don't attempt to do it in
+		 * the database_check function which the daemon
+		 * calls.
+		 */
+		priv->reindexed_on_init = TRUE;
 	}
 
 	index_file = g_build_filename (priv->db_dir, "file-index.db", NULL);
@@ -597,6 +603,72 @@
 }
 
 gboolean
+tracker_indexer_database_check (TrackerIndexer  *indexer,
+				gboolean         force_reindex,
+				gboolean        *first_time_index,
+				GError         **error)
+{
+	TrackerIndexerPrivate *priv;
+	guint                  request_id;
+
+	tracker_dbus_return_val_if_fail (TRACKER_IS_INDEXER (indexer), 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 check database health");
+
+	if (G_UNLIKELY (force_reindex)) {
+		*first_time_index = TRUE;
+
+		/* If we reindexed on initialization, don't do it
+		 * again here.
+		 */ 
+		if (!priv->reindexed_on_init) {
+			reindex_database (indexer);
+		}
+	} else {
+		/* Is this the first time? */
+		*first_time_index = tracker_db_manager_need_reindex ();
+		
+		if (*first_time_index) {
+			/* Create new databases */
+			tracker_dbus_request_comment (request_id, 
+						      "Creating databases...");
+			tracker_db_manager_create_all (FALSE);
+		}
+	}
+		
+	tracker_dbus_request_success (request_id);
+
+	return TRUE;
+}
+
+gboolean
+tracker_indexer_database_reindex (TrackerIndexer  *indexer,
+				  GError         **error)
+{
+	TrackerIndexerPrivate *priv;
+	guint                  request_id;
+
+	tracker_dbus_return_val_if_fail (TRACKER_IS_INDEXER (indexer), 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 reindex the database");
+
+
+	reindex_database (indexer);
+	
+	tracker_dbus_request_success (request_id);
+
+	return TRUE;
+}
+
+gboolean
 tracker_indexer_set_running (TrackerIndexer  *indexer,
 			     gboolean         should_be_running,
 			     GError         **error)
@@ -659,7 +731,7 @@
 }
 
 gboolean
-tracker_indexer_check_files (TrackerIndexer  *indexer,
+tracker_indexer_files_check (TrackerIndexer  *indexer,
 			     GStrv            files,
 			     GError         **error)
 {
@@ -702,7 +774,7 @@
 }
 
 gboolean
-tracker_indexer_update_files (TrackerIndexer  *indexer,
+tracker_indexer_files_update (TrackerIndexer  *indexer,
 			      GStrv            files,
 			      GError         **error)
 {
@@ -745,7 +817,7 @@
 }
 
 gboolean
-tracker_indexer_delete_files (TrackerIndexer  *indexer,
+tracker_indexer_files_delete (TrackerIndexer  *indexer,
 			      GStrv            files,
 			      GError         **error)
 {
@@ -787,25 +859,3 @@
 	return TRUE;
 }
 
-gboolean
-tracker_indexer_reindex (TrackerIndexer  *indexer,
-			 GError         **error)
-{
-	TrackerIndexerPrivate *priv;
-	guint                  request_id;
-
-	tracker_dbus_return_val_if_fail (TRACKER_IS_INDEXER (indexer), 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 reindex the database");
-
-
-	reindex_database (indexer);
-	
-	tracker_dbus_request_success (request_id);
-
-	return TRUE;
-}

Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer.h
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer.h	(original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer.h	Thu Jun 19 17:06:28 2008
@@ -51,25 +51,29 @@
 	void (*index_updated) (TrackerIndexer *indexer);
 };
 
-GType           tracker_indexer_get_type     (void) G_GNUC_CONST;
-TrackerIndexer *tracker_indexer_new          (void);
-gboolean        tracker_indexer_set_running  (TrackerIndexer  *indexer,
-					      gboolean         should_be_running,
-					      GError         **error);
-gboolean        tracker_indexer_get_running  (TrackerIndexer  *indexer,
-					      gboolean        *is_running,
-					      GError         **error);
-gboolean        tracker_indexer_check_files  (TrackerIndexer  *indexer,
-					      GStrv            files,
-					      GError         **error);
-gboolean        tracker_indexer_update_files (TrackerIndexer  *indexer,
-					      GStrv            files,
-					      GError         **error);
-gboolean        tracker_indexer_delete_files (TrackerIndexer  *indexer,
-					      GStrv            files,
-					      GError         **error);
-gboolean        tracker_indexer_reindex      (TrackerIndexer  *indexer,
-					      GError         **error);
+GType           tracker_indexer_get_type       (void) G_GNUC_CONST;
+TrackerIndexer *tracker_indexer_new              (void);
+gboolean        tracker_indexer_database_check   (TrackerIndexer  *indexer,
+						  gboolean         force_reindex,
+						  gboolean        *first_time_index,
+						  GError         **error);
+gboolean        tracker_indexer_database_reindex (TrackerIndexer  *indexer,
+						  GError         **error);
+gboolean        tracker_indexer_set_running      (TrackerIndexer  *indexer,
+						  gboolean         should_be_running,
+						  GError         **error);
+gboolean        tracker_indexer_get_running      (TrackerIndexer  *indexer,
+						  gboolean        *is_running,
+						  GError         **error);
+gboolean        tracker_indexer_files_check      (TrackerIndexer  *indexer,
+						  GStrv            files,
+						  GError         **error);
+gboolean        tracker_indexer_files_update     (TrackerIndexer  *indexer,
+						  GStrv            files,
+						  GError         **error);
+gboolean        tracker_indexer_files_delete     (TrackerIndexer  *indexer,
+						  GStrv            files,
+						  GError         **error);
 
 G_END_DECLS
 

Modified: branches/indexer-split/src/tracker-indexer/tracker-main.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-main.c	(original)
+++ branches/indexer-split/src/tracker-indexer/tracker-main.c	Thu Jun 19 17:06:28 2008
@@ -149,14 +149,14 @@
                                           "data", 
                                           NULL);
 
-	filename = g_strdup_printf ("Tracker-%s.%d", g_get_user_name (), getpid ());
+	filename = g_strdup_printf ("tracker-%s", g_get_user_name ());
 	sys_tmp_dir = g_build_filename (g_get_tmp_dir (), filename, NULL);
 	g_free (filename);
 
 	tracker_db_manager_init (FALSE, data_dir, user_data_dir, sys_tmp_dir);
 
         if (reindex) {
-                tracker_db_manager_set_up_databases (TRUE);
+                tracker_db_manager_create_all (TRUE);
         }
 
 	g_free (data_dir);

Modified: branches/indexer-split/src/tracker-indexer/tracker-metadata.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-metadata.c	(original)
+++ branches/indexer-split/src/tracker-indexer/tracker-metadata.c	Thu Jun 19 17:06:28 2008
@@ -80,7 +80,7 @@
 		gchar *temp_filename;
 		gint   fd;
 
-                filename = g_strdup_printf ("Tracker-%s.%d", g_get_user_name (), getpid ());
+                filename = g_strdup_printf ("tracker-%s", g_get_user_name ());
                 sys_tmp_dir = g_build_filename (g_get_tmp_dir (), filename, NULL);
                 g_free (filename);
                 

Modified: branches/indexer-split/src/trackerd/tracker-crawler.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-crawler.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-crawler.c	Thu Jun 19 17:06:28 2008
@@ -883,7 +883,7 @@
 	g_debug ("File check queue processed, sending first %d to the indexer", 
 		 g_strv_length (files));
 	
-	org_freedesktop_Tracker_Indexer_check_files_async (proxy, 
+	org_freedesktop_Tracker_Indexer_files_check_async (proxy, 
 							   (const gchar **) files,
 							   indexer_check_files_cb,
 							   files);

Modified: branches/indexer-split/src/trackerd/tracker-dbus.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-dbus.c	Thu Jun 19 17:06:28 2008
@@ -311,39 +311,6 @@
         return NULL;
 }
 
-void
-tracker_dbus_indexer_start (void)
-{
-	GError *error = NULL;
-
-	if (!connection) {
-		g_critical ("DBus support must be initialized before starting the indexer!");
-		return;
-	}
-
-	if (!proxy_for_indexer) {
-		/* Get proxy for Service / Path / Interface of the indexer */
-		proxy_for_indexer = dbus_g_proxy_new_for_name (connection,
-							       "org.freedesktop.Tracker.Indexer", 
- 							       "/org/freedesktop/Tracker/Indexer",
-							       "org.freedesktop.Tracker.Indexer");
-		
-		if (!proxy_for_indexer) {
-			g_critical ("Couldn't create a DBusGProxy to the indexer service");
-			return;
-		}
-	}
-
-	org_freedesktop_Tracker_Indexer_set_running (proxy_for_indexer, 
-						     TRUE, 
-						     &error);
-
-	if (error) {
-		g_warning ("Couldn't start indexer, %s",
-			   error->message);
-	}
-}
-
 DBusGProxy *
 tracker_dbus_indexer_get_proxy (void)
 {

Modified: branches/indexer-split/src/trackerd/tracker-dbus.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus.h	(original)
+++ branches/indexer-split/src/trackerd/tracker-dbus.h	Thu Jun 19 17:06:28 2008
@@ -37,7 +37,6 @@
 void        tracker_dbus_shutdown          (void);
 gboolean    tracker_dbus_register_objects  (Tracker       *tracker);
 GObject    *tracker_dbus_get_object        (GType          type);
-void        tracker_dbus_indexer_start     (void);
 DBusGProxy *tracker_dbus_indexer_get_proxy (void);
 
 G_END_DECLS

Modified: branches/indexer-split/src/trackerd/tracker-main.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-main.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-main.c	Thu Jun 19 17:06:28 2008
@@ -49,6 +49,7 @@
 #include "tracker-crawler.h"
 #include "tracker-dbus.h"
 #include "tracker-indexer.h"
+#include "tracker-indexer-client.h"
 #include "tracker-monitor.h"
 #include "tracker-process-files.h"
 #include "tracker-status.h"
@@ -353,27 +354,6 @@
 			 "File types excluded from indexing");
 }
 
-static void
-create_index (gboolean need_data)
-{
-	TrackerDBInterface *iface;
-	
-	tracker->first_time_index = TRUE;
-
-	/* Reset stats for embedded services if they are being reindexed */
-	if (!need_data) {
-		iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
-
-		g_message ("*** DELETING STATS *** ");
-		tracker_db_exec_no_reply (iface, 
-					  "update ServiceTypes set TypeCount = 0 where Embedded = 1");
-	}
-
-	/* Create databases */
-
-	/* create file content, email content and email dbs */
-}
-
 static gboolean 
 shutdown_timeout_cb (gpointer user_data)
 {
@@ -457,7 +437,7 @@
 				     "tracker", 
 				     NULL);
 
-	filename = g_strdup_printf ("Tracker-%s.%d", g_get_user_name (), getpid ());
+	filename = g_strdup_printf ("tracker-%s", g_get_user_name ());
 	sys_tmp_dir = g_build_filename (g_get_tmp_dir (), filename, NULL);
 	g_free (filename);
 
@@ -469,11 +449,13 @@
 }
 
 static void
-initialize_directories (gboolean *need_index)
+initialize_directories (void)
 {
 	gchar *filename;
 
-	*need_index = FALSE;
+	/* NOTE: We don't create the database directories here, the
+	 * tracker-db-manager does that for us.
+	 */ 
 	
 	/* Remove an existing one */
 	if (g_file_test (sys_tmp_dir, G_FILE_TEST_EXISTS)) {
@@ -490,20 +472,6 @@
 	g_free (filename);
 
 	/* Remove database if we are reindexing */
-	if (reindex) {
-		tracker_path_remove (data_dir);
-		*need_index = TRUE;
-	}
-
-        /* Create other directories we need */
-	if (!g_file_test (user_data_dir, G_FILE_TEST_EXISTS)) {
-		g_mkdir_with_parents (user_data_dir, 00755);
-	}
-
-	if (!g_file_test (data_dir, G_FILE_TEST_EXISTS)) {
-		g_mkdir_with_parents (data_dir, 00755);
-	}
-
         filename = g_build_filename (sys_tmp_dir, "Attachments", NULL);
 	g_mkdir_with_parents (filename, 00700);
 	g_free (filename);
@@ -512,22 +480,59 @@
 	tracker_file_unlink (log_filename);
 }
 
-static void
-initialize_databases (gboolean need_index)
+static gboolean
+initialize_databases (void)
 {
-	Indexer  *index;
-	gchar    *final_index_name;
-	gboolean  need_data;
-	
-	if (!tracker->readonly && need_index) {
-		create_index (need_data);
-	} else {
-		tracker->first_time_index = FALSE;
+	DBusGProxy *proxy;
+	GError     *error = NULL;
+	Indexer    *index;
+	gchar      *final_index_name;
+	gboolean    success;
+
+	/* We use the blocking variant of this call here because
+	 * until we know the response, the daemon can't do anything
+	 * anyway.
+	 */
+	g_message ("Checking the database is ready, this may take a few moments, please wait..."); 
+
+	proxy = tracker_dbus_indexer_get_proxy ();
+	success = org_freedesktop_Tracker_Indexer_database_check (proxy, 
+								  reindex,
+								  &tracker->first_time_index, 
+								  &error);
+
+	if (!success || error) {
+		if (error) {
+			g_critical (error->message);
+			g_error_free (error);
+		}
+
+		g_critical ("Could not check the database status, "
+			    "can not start without the database!");
+
+		return FALSE;
+	}
+
+	/*
+	 * Create SQLite databases 
+	 */
+	if (!tracker->readonly && reindex) {
+		TrackerDBInterface *iface;
+		
+		tracker->first_time_index = TRUE;
+		
+		/* Reset stats for embedded services if they are being reindexed */
+		iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+		
+		g_message ("*** DELETING STATS *** ");
+		tracker_db_exec_no_reply (iface, 
+					  "update ServiceTypes set TypeCount = 0 where Embedded = 1");
+		
 	}
 
 	/* Check db integrity if not previously shut down cleanly */
 	if (!tracker->readonly && 
-	    !need_index && 
+	    !tracker->first_time_index && 
 	    tracker_db_get_option_int ("IntegrityCheck") == 1) {
 		g_message ("Performing integrity check as the daemon was not shutdown cleanly");
 		/* FIXME: Finish */
@@ -541,8 +546,8 @@
 		tracker_db_set_option_int ("InitialIndex", 1);
 	}
 
-	/* Move final file to index file if present and no files left
-	 * to merge.
+	/*
+	 * Create index files
 	 */
 	final_index_name = g_build_filename (data_dir, "file-index-final", NULL);
 	
@@ -595,6 +600,8 @@
 	tracker->email_index = index;
 
 	/* db_con->word_index = tracker->file_index; */
+
+	return TRUE;
 }
 
 static gboolean
@@ -695,7 +702,6 @@
 	GOptionGroup   *group;
 	GError         *error = NULL;
 	GSList         *l;
-	gboolean        need_index;
 
         g_type_init ();
         
@@ -823,7 +829,7 @@
 
 	sanity_check_option_values ();
 
-	initialize_directories (&need_index);
+	initialize_directories ();
 
 	tracker_nfs_lock_init (tracker_config_get_nfs_locking (tracker->config));
 	tracker_db_init ();
@@ -844,7 +850,9 @@
 
 	tracker->readonly = check_multiple_instances ();
 
-	initialize_databases (need_index);
+	if (!initialize_databases ()) {
+		return EXIT_FAILURE;
+	}
 
 	/* Set our status as running, if this is FALSE, threads stop
 	 * doing what they do and shutdown.

Modified: branches/indexer-split/src/trackerd/tracker-monitor.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-monitor.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-monitor.c	Thu Jun 19 17:06:28 2008
@@ -168,7 +168,7 @@
 	if (g_strv_length (files) > 0) {
 		g_debug ("Files deleted queue processed, sending first %d to the indexer", 
 			 g_strv_length (files));
-		org_freedesktop_Tracker_Indexer_delete_files_async (proxy, 
+		org_freedesktop_Tracker_Indexer_files_delete_async (proxy, 
 								    (const gchar **) files,
 								    indexer_files_processed_cb,
 								    files);
@@ -181,7 +181,7 @@
 	if (g_strv_length (files) > 0) {
 		g_debug ("Files created queue processed, sending first %d to the indexer", 
 			 g_strv_length (files));
-		org_freedesktop_Tracker_Indexer_check_files_async (proxy, 
+		org_freedesktop_Tracker_Indexer_files_check_async (proxy, 
 								   (const gchar **) files,
 								   indexer_files_processed_cb,
 								   files);
@@ -195,7 +195,7 @@
 	if (g_strv_length (files) > 0) {
 		g_debug ("Files updated queue processed, sending first %d to the indexer", 
 			 g_strv_length (files));
-		org_freedesktop_Tracker_Indexer_update_files_async (proxy, 
+		org_freedesktop_Tracker_Indexer_files_update_async (proxy, 
 								    (const gchar **) files,
 								    indexer_files_processed_cb,
 								    files);



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