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



Author: mr
Date: Fri Jun 20 10:17:48 2008
New Revision: 1720
URL: http://svn.gnome.org/viewvc/tracker?rev=1720&view=rev

Log:
	* data/dbus/tracker-indexer.xml: 
	* src/tracker-indexer/tracker-indexer.[ch]: Removed
	DatabaseReindex and DatabaseCheck, now the daemon ALWAYS makes
	sure the database is ready instead of the indexer.

	* data/sqlite-tracker.sql: Remove the ANALYZE statement after
	creating the tables, this is what was causing the hang when
	attaching ALL databases during creation.

	* src/tracker-indexer/tracker-main.c: No need to check if a
	reindex is required now and removed all reindex command line
	options. 

	* src/trackerd/tracker-main.c: Don't call the indexer over dbus,
	just rely on tracker_db_manager_init() to set up the databases
	correctly and to check if they exist properly.


Modified:
   branches/indexer-split/ChangeLog
   branches/indexer-split/data/dbus/tracker-indexer.xml
   branches/indexer-split/data/sqlite-tracker.sql
   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/trackerd/tracker-main.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	Fri Jun 20 10:17:48 2008
@@ -10,13 +10,6 @@
 
 <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>

Modified: branches/indexer-split/data/sqlite-tracker.sql
==============================================================================
--- branches/indexer-split/data/sqlite-tracker.sql	(original)
+++ branches/indexer-split/data/sqlite-tracker.sql	Fri Jun 20 10:17:48 2008
@@ -81,5 +81,3 @@
 	primary key (Path, Name)
 
 );
-
-ANALYZE;

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	Fri Jun 20 10:17:48 2008
@@ -25,6 +25,8 @@
 #include <regex.h>
 #include <zlib.h>
 
+#include <glib/gstdio.h>
+
 #include <libtracker-common/tracker-field.h>
 #include <libtracker-common/tracker-file-utils.h>
 #include <libtracker-common/tracker-nfs-lock.h>
@@ -35,7 +37,10 @@
 #include "tracker-db-manager.h"
 #include "tracker-db-interface-sqlite.h"
 
-#define ZLIBBUFSIZ 8192
+#define TRACKER_DB_PAGE_SIZE_DEFAULT  4096
+#define TRACKER_DB_PAGE_SIZE_DONT_SET -1
+
+#define ZLIBBUFSIZ                    8192
 
 typedef enum {
         TRACKER_DB_LOCATION_DATA_DIR,
@@ -129,11 +134,11 @@
 static gboolean            initialized;
 static gboolean            attach_all;
 static GHashTable         *prepared_queries;
-static gchar              *db_services_dir;
-static gchar              *db_sql_dir;
-static gchar              *db_data_dir;
-static gchar              *db_user_data_dir;
-static gchar              *db_sys_tmp_dir;
+static gchar              *services_dir;
+static gchar              *sql_dir;
+static gchar              *data_dir;
+static gchar              *user_data_dir;
+static gchar              *sys_tmp_dir;
 static gpointer            db_type_enum_class_pointer;
 static TrackerDBInterface *attach_interface = NULL;
 
@@ -142,11 +147,11 @@
 {
         switch (location) {
         case TRACKER_DB_LOCATION_DATA_DIR:
-                return db_data_dir;
+                return data_dir;
         case TRACKER_DB_LOCATION_USER_DATA_DIR:
-                return db_user_data_dir;
+                return user_data_dir;
         case TRACKER_DB_LOCATION_SYS_TMP_DIR:
-                return db_sys_tmp_dir;
+                return sys_tmp_dir;
         };
 
 	return NULL;
@@ -177,7 +182,7 @@
 	gchar *path, *content, **queries;
 	gint i;
 
-	path = g_build_filename (db_sql_dir, file, NULL);
+	path = g_build_filename (sql_dir, file, NULL);
 
 	if (!delimiter) {
 		delimiter = ";";
@@ -213,7 +218,7 @@
 	gint           id, i, j;
 
 	key_file = g_key_file_new ();
-	service_file = g_build_filename (db_services_dir, filename, NULL);
+	service_file = g_build_filename (services_dir, filename, NULL);
 
 	if (!g_key_file_load_from_file (key_file, service_file, G_KEY_FILE_NONE, NULL)) {
 		g_free (service_file);
@@ -304,7 +309,7 @@
 	gchar          **groups, **keys;
 	gint             i, j, id;
 
-	service_file = g_build_filename (db_services_dir, filename, NULL);
+	service_file = g_build_filename (services_dir, filename, NULL);
 
 	key_file = g_key_file_new ();
 
@@ -599,7 +604,7 @@
 	};
 
 	key_file = g_key_file_new ();
-	service_file = g_build_filename (db_services_dir, filename, NULL);
+	service_file = g_build_filename (services_dir, filename, NULL);
 
 	if (!g_key_file_load_from_file (key_file, service_file, G_KEY_FILE_NONE, &error)) {
 		g_critical ("Couldn't load XESAM service file:'%s', %s",
@@ -795,7 +800,7 @@
 
 	g_message ("Loading prepared queries...");
 
-	filename = g_build_filename (db_sql_dir, "sqlite-stored-procs.sql", NULL);
+	filename = g_build_filename (sql_dir, "sqlite-stored-procs.sql", NULL);
 
 	t = g_timer_new ();
 
@@ -1639,7 +1644,7 @@
 	TrackerDBInterface *iface;
 	const gchar        *path;
 
-	path = tracker_db_manager_get_file (type);
+	path = dbs[type].abs_filename;
 
 	if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
 		*create = TRUE;
@@ -1652,35 +1657,40 @@
 		   path,
 		   db_type_to_string (type));
 
-	if (attach_all && attach_interface) {
-		iface = g_object_ref (attach_interface);
-	} else {
-		iface = tracker_db_interface_sqlite_new (path);
-		tracker_db_interface_set_procedure_table (iface, prepared_queries);
-
-		if (attach_all) {
-			attach_interface = g_object_ref (iface);
+	if (attach_all) {
+		if (!attach_interface) {
+			attach_interface = tracker_db_interface_sqlite_new (path);
+			tracker_db_interface_set_procedure_table (attach_interface, 
+								  prepared_queries);
+
+			/* We don't have separate interfaces for each db in
+			 * this situation. We just have one interface.
+			 * One analyze when we create interfaces.
+			 */
+			g_message ("  Analyzing...");
+			db_exec_no_reply (attach_interface, "ANALYZE");
 		}
 
-		db_exec_no_reply (iface, "ANALYZE");
-	}
-
-	/* FIXME: Shouldn't we do this for common/cache dbs too? */
-	if (!attach_all &&
-	    type != TRACKER_DB_COMMON &&
-	    type != TRACKER_DB_CACHE) {
-		db_set_params (iface,
-			       dbs[type].cache_size,
-			       dbs[type].page_size,
-			       dbs[type].add_functions);
-	}
-
-	if (attach_all) {
-		g_message ("  Attaching to current DB connection");
-		db_exec_no_reply (iface, 
+		g_message ("  Attaching");
+		db_exec_no_reply (attach_interface, 
 				  "ATTACH '%s' as %s",
 				  dbs[type].abs_filename,
 				  dbs[type].name);
+
+		iface = attach_interface;
+	} else {
+		iface = tracker_db_interface_sqlite_new (path);
+		tracker_db_interface_set_procedure_table (iface, 
+							  prepared_queries);
+
+		/* FIXME: Shouldn't we do this for common/cache dbs too? */
+		if (type != TRACKER_DB_COMMON &&
+		    type != TRACKER_DB_CACHE) {
+			db_set_params (iface,
+				       dbs[type].cache_size,
+				       dbs[type].page_size,
+				       dbs[type].add_functions);
+		}
 	}
 
 	return iface;
@@ -2024,22 +2034,6 @@
 		db_xesam_create_lookup (iface);
 	}
 
-	/* db_exec_no_reply (iface, */
-	/* 		  "ATTACH '%s' as 'file-meta'", */
-	/* 		  tracker_db_manager_get_file (TRACKER_DB_FILE_METADATA)); */
-
-	/* db_exec_no_reply (iface, */
-	/* 		  "ATTACH '%s' as 'email-meta'", */
-	/* 		  tracker_db_manager_get_file (TRACKER_DB_EMAIL_METADATA)); */
-
-	/* db_exec_no_reply (iface, */
-	/* 		  "ATTACH '%s' as 'common'", */
-	/* 		  tracker_db_manager_get_file (TRACKER_DB_COMMON)); */
-
-	/* db_exec_no_reply (iface, */
-	/* 		  "ATTACH '%s' as 'cache'", */
-	/* 		  tracker_db_manager_get_file (TRACKER_DB_CACHE)); */
-
 	/* Load static xesam data */
 	db_get_static_xesam_data (iface);
 
@@ -2117,26 +2111,24 @@
 }
 
 void
-tracker_db_manager_init (gboolean     attach_all_dbs,
-			 const gchar *data_dir, 
-                         const gchar *user_data_dir,
-                         const gchar *sys_tmp_dir) 
-{
-	GType etype;
-
-        g_return_if_fail (data_dir != NULL);
-        g_return_if_fail (user_data_dir != NULL);
-        g_return_if_fail (sys_tmp_dir != NULL);
+tracker_db_manager_init (gboolean  attach_all_dbs,
+			 gboolean  force_reindex,
+			 gboolean *first_time_index)
+{
+	GType        etype;
+	gchar       *filename;
+	const gchar *dir;
+	gboolean     need_reindex;
+	guint        i;
+
+	if (first_time_index) {
+		*first_time_index = FALSE;
+	}
 
         if (initialized) {
 		return;
 	}
 
-	/* Make sure we initialize all other modules we depend on */
-	tracker_ontology_init ();
-	
-	attach_all = attach_all_dbs;
-
 	/* Since we don't reference this enum anywhere, we do
 	 * it here to make sure it exists when we call
 	 * g_type_class_peek(). This wouldn't be necessary if
@@ -2150,29 +2142,64 @@
 	db_type_enum_class_pointer = g_type_class_ref (etype);
 
 	/* Set up locations */
-	db_services_dir = g_build_filename (SHAREDIR, 
+	g_message ("Setting database locations");
+
+	services_dir = g_build_filename (SHAREDIR, 
 					    "tracker", 
 					    "services", 
 					    NULL);
-	db_sql_dir = g_build_filename (SHAREDIR, 
+	sql_dir = g_build_filename (SHAREDIR, 
 				       "tracker", 
 				       NULL);
-	db_data_dir = g_strdup (data_dir);
-	db_user_data_dir = g_strdup (user_data_dir);
-	db_sys_tmp_dir = g_strdup (sys_tmp_dir);
-
-	/* 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);
+	user_data_dir = g_build_filename (g_get_user_data_dir (), 
+                                          "tracker", 
+                                          "data", 
+                                          NULL);
+
+	data_dir = g_build_filename (g_get_user_cache_dir (), 
+				     "tracker", 
+				     NULL);
+
+	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);
+
+	/* Make sure the directories exist */
+	g_message ("Checking database directories exist");
 
-	g_mkdir_with_parents (db_data_dir, 00755);
-	g_mkdir_with_parents (db_user_data_dir, 00755);
+	g_mkdir_with_parents (data_dir, 00755);
+	g_mkdir_with_parents (user_data_dir, 00755);
+	g_mkdir_with_parents (sys_tmp_dir, 00755);
+
+	g_message ("Checking database files exist");
+
+        for (i = 0, need_reindex = FALSE; i < G_N_ELEMENTS (dbs); i++) {
+                /* Fill absolute path for the database */
+                dir = location_to_directory (dbs[i].location);
+		dbs[i].abs_filename = g_build_filename (dir, dbs[i].file, NULL);
+
+		/* Check we have each database in place, if one is
+		 * missing, we reindex, except the cache which we
+		 * expect to be replaced on each startup.
+		 */
+		if (i == TRACKER_DB_CACHE) {
+			continue;
+		}
+		
+		/* No need to check for other files not existing (for
+		 * reindex) if one is already missing. 
+		 */
+		if (need_reindex) {
+			continue;
+		}
+
+		if (!g_file_test (dbs[i].abs_filename, G_FILE_TEST_EXISTS)) { 
+			g_message ("Could not find database file:'%s'", dbs[i].abs_filename);
+			g_message ("One or more database files are missing, a reindex will be forced");
+			need_reindex = TRUE;
+		}
+        }
 
 	/* Add prepared queries */
 	prepared_queries = g_hash_table_new_full (g_str_hash,
@@ -2182,13 +2209,85 @@
 
 	load_prepared_queries ();
 
-	/* Needs to be BEFORE the set_up_databases, since it uses
-	 * public API calls which check we are initialized.
+	/* Should we reindex? If so, just remove all databases files,
+	 * NOT the paths, note, that these paths are also used for
+	 * other things like the nfs lock file.
 	 */
-	initialized = TRUE;
+	if (force_reindex || need_reindex) {
+		if (first_time_index) {
+			*first_time_index = TRUE;
+		}
+
+		g_message ("Removing database files for reindex");
+
+		for (i = 0; i < G_N_ELEMENTS (dbs); i++) {
+			g_message ("Removing database:'%s'", 
+				   dbs[i].abs_filename);
+			g_unlink (dbs[i].abs_filename);
+		}
+
+		/* Don't attach while we do this... */
+		attach_all = FALSE;
+
+		/* In cases where we re-init this module, make sure
+		 * we have cleaned up the ontology before we load all
+		 * new databases.
+		 */
+		tracker_ontology_shutdown ();
+
+		/* Make sure we initialize all other modules we depend on */
+		tracker_ontology_init ();
+		
+		/* Now create the databases and close them */
+		g_message ("Creating database files, this may take a few moments...");
+
+		for (i = 0; i < G_N_ELEMENTS (dbs); i++) {
+			TrackerDBInterface *iface;
+			
+			iface = db_interface_create (i);
+			
+			if (!attach_all) {
+				dbs[i].iface = iface;
+			}
+		}
 
-	/* Configure database locations and interfaces */
-	set_up_databases ();
+		/* When attaching all, we have 2 references per
+		 * interface, one for the dbs and one for the
+		 * singletone interface, we need to unref both and
+		 * set the attach interface to NULL to close all
+		 * databases.
+		 */
+		g_object_unref (attach_interface);
+		attach_interface = NULL;
+	} else {
+		/* Make sure we remove and recreate the cache directory in tmp
+		 * each time we start up, this is meant to be a per-run
+		 * thing.
+		 */
+		g_message ("Removing cache database:'%s'", 
+			   dbs[TRACKER_DB_CACHE].abs_filename);
+		g_unlink (dbs[TRACKER_DB_CACHE].abs_filename);
+
+		/* Make sure we initialize all other modules we depend on */
+		tracker_ontology_init ();
+	}
+
+	attach_all = attach_all_dbs;
+
+	/* Load databases */
+	g_message ("Loading databases files...");
+
+	for (i = 0; i < G_N_ELEMENTS (dbs); i++) {
+		TrackerDBInterface *iface;
+
+		iface = db_interface_create (i);
+
+		if (!attach_all) {
+			dbs[i].iface = iface;
+		}
+	}
+
+	initialized = TRUE;
 }
 
 void
@@ -2216,14 +2315,14 @@
 	prepared_queries = NULL;
 
 	/* Remove directory in tmp */
-	g_message ("Removing directory:'%s'", db_sys_tmp_dir);
-	tracker_path_remove (db_sys_tmp_dir);
+	g_message ("Removing directory:'%s'", sys_tmp_dir);
+	tracker_path_remove (sys_tmp_dir);
 
-	g_free (db_data_dir);
-	g_free (db_user_data_dir);
-	g_free (db_sys_tmp_dir);
-        g_free (db_services_dir);
-        g_free (db_sql_dir);
+	g_free (data_dir);
+	g_free (user_data_dir);
+	g_free (sys_tmp_dir);
+        g_free (services_dir);
+        g_free (sql_dir);
 
 	/* Since we don't reference this enum anywhere, we do
 	 * it here to make sure it exists when we call
@@ -2247,96 +2346,6 @@
         initialized = FALSE;
 }
 
-gboolean
-tracker_db_manager_need_reindex (void) 
-{
-	g_return_val_if_fail (initialized != FALSE, FALSE);
-
-	if (!g_file_test (db_data_dir, G_FILE_TEST_EXISTS)) {
-		return TRUE;
-	}
-
-	if (!g_file_test (db_user_data_dir, G_FILE_TEST_EXISTS)) {
-		return TRUE;
-	}
-
-	return FALSE;
-}
-
-void
-tracker_db_manager_close_all (void)
-{
-	guint i;
-
-	/* Close all dbs first. */
-        for (i = 0; i < G_N_ELEMENTS (dbs); i++) {
-		if (dbs[i].iface) {
-			g_object_unref (dbs[i].iface);
-			dbs[i].iface = NULL;
-		}
-        }
-}
-
-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);
-	
-	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;
-
-	/* Don't attach while we do this... */
-	attach_all = FALSE;
-
-	/* 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 */
-	g_message ("Creating directory:'%s'", db_data_dir);
-	g_mkdir_with_parents (db_data_dir, 00755);
-
-	g_message ("Creating directory:'%s'", db_user_data_dir);
-	g_mkdir_with_parents (db_user_data_dir, 00755);
-
-	g_message ("Creating directory:'%s'", db_sys_tmp_dir);
-	g_mkdir_with_parents (db_sys_tmp_dir, 00755);
-
-	/* Reinitialize ontology */
-	tracker_ontology_shutdown ();
-	tracker_ontology_init ();
-
-	/* Now we close these databases again and wait for the next
-	 * time they are needed.
-	 */
-	tracker_db_manager_close_all ();
-
-	/* Set the attach setting back to what it was */
-	attach_all = current_attach_all;
-}
-
 const gchar *
 tracker_db_manager_get_file (TrackerDB db) 
 {
@@ -2350,8 +2359,8 @@
 {
 	g_return_val_if_fail (initialized != FALSE, NULL);
 
-	if (!dbs[db].iface) {
-		dbs[db].iface = db_interface_create (db);
+	if (attach_all) {
+		return attach_interface;
 	}
 
 	return dbs[db].iface;

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	Fri Jun 20 10:17:48 2008
@@ -25,9 +25,6 @@
 
 #include "tracker-db-interface.h"
 
-#define TRACKER_DB_PAGE_SIZE_DEFAULT  4096
-#define TRACKER_DB_PAGE_SIZE_DONT_SET -1
-
 G_BEGIN_DECLS
 
 #define TRACKER_TYPE_DB (tracker_db_get_type ())
@@ -45,15 +42,11 @@
 GType        tracker_db_get_type                            (void) G_GNUC_CONST;
 
 void         tracker_db_manager_init                        (gboolean            attach_all_dbs,
-							     const gchar        *data_dir,
-							     const gchar        *user_data_dir,
-							     const gchar        *sys_tmp_root_dir);
+							     gboolean            force_reindex,
+							     gboolean           *first_time_index);
 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);
 
 const gchar *tracker_db_manager_get_file                    (TrackerDB           db);
 TrackerDBInterface *

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	Fri Jun 20 10:17:48 2008
@@ -87,8 +87,6 @@
 	TrackerLanguage *language;
 
 	guint idle_id;
-
-	gboolean reindexed_on_init;
 };
 
 struct PathInfo {
@@ -142,27 +140,6 @@
 }
 
 static void
-reindex_database (TrackerIndexer *indexer)
-{
-	TrackerIndexerPrivate *priv;
-
-	priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
-
-	/* These are unreffed for us by the TrackerDBManager */
-	priv->common = NULL;
-	priv->metadata = NULL;
-	priv->contents = NULL;
-	
-	/* Now create the new databases */
-	tracker_db_manager_create_all (TRUE);
-
-	/* Now establish new connections */
-	priv->common = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON);
-	priv->metadata = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
-	priv->contents = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_CONTENTS);
-}
-
-static void
 tracker_indexer_finalize (GObject *object)
 {
 	TrackerIndexerPrivate *priv;
@@ -304,16 +281,6 @@
 		}
 	}
 	
-	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);
 
 	priv->index = tracker_index_new (index_file,
@@ -603,72 +570,6 @@
 }
 
 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)

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	Fri Jun 20 10:17:48 2008
@@ -53,12 +53,6 @@
 
 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);

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	Fri Jun 20 10:17:48 2008
@@ -57,7 +57,6 @@
 static GMainLoop    *main_loop;
  
 static gint          verbosity = -1;
-static gboolean      reindex;
 
 static GOptionEntry  entries[] = {
 	{ "verbosity", 'v', 0, 
@@ -65,10 +64,6 @@
 	  N_("Logging, 0 = errors only, "
 	     "1 = minimal, 2 = detailed and 3 = debug (default = 0)"), 
 	  NULL },
-	{ "reindex", 'r', 0, 
-          G_OPTION_ARG_NONE, &reindex, 
-	  N_("Force a re-index of all content"), 
-	  NULL },
 	{ NULL }
 };
 
@@ -153,11 +148,7 @@
 	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_create_all (TRUE);
-        }
+	tracker_db_manager_init (FALSE, FALSE, NULL);
 
 	g_free (data_dir);
 	g_free (user_data_dir);

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	Fri Jun 20 10:17:48 2008
@@ -489,35 +489,8 @@
 static gboolean
 initialize_databases (void)
 {
-	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;
-	}
+	Indexer *index;
+	gchar   *final_index_name;
 
 	/*
 	 * Create SQLite databases 
@@ -837,8 +810,8 @@
 	sanity_check_option_values ();
 
 	tracker_nfs_lock_init (tracker_config_get_nfs_locking (tracker->config));
+	tracker_db_manager_init (TRUE, reindex, &tracker->first_time_index); 
 	tracker_db_init ();
-	tracker_db_manager_init (TRUE, data_dir, user_data_dir, sys_tmp_dir); /* Using TRUE=broken */
 	tracker_xesam_manager_init ();
 	tracker_email_start_email_watching (tracker_config_get_email_client (tracker->config));
 
@@ -918,8 +891,8 @@
 	tracker_email_end_email_watching ();
 	tracker_dbus_shutdown ();
 	tracker_xesam_manager_shutdown ();
-	tracker_db_shutdown ();
 	tracker_db_manager_shutdown ();
+	tracker_db_shutdown ();
 	tracker_monitor_shutdown ();
 	tracker_nfs_lock_shutdown ();
 	tracker_log_shutdown ();



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