tracker r1609 - in branches/indexer-split: . src/libtracker-db



Author: carlosg
Date: Mon Jun  9 15:17:36 2008
New Revision: 1609
URL: http://svn.gnome.org/viewvc/tracker?rev=1609&view=rev

Log:
2008-06-09  Carlos Garnacho  <carlos imendio com>

        * src/libtracker-db/tracker-db-manager.c (set_up_databases)
        (db_interface_create) (tracker_db_manager_init)
        (tracker_db_manager_shutdown) (tracker_db_manager_get_db_interface)
        (tracker_db_manager_get_db_interface_content): Allow creating
        databases lazily, instead of creating them all on initialization.


Modified:
   branches/indexer-split/ChangeLog
   branches/indexer-split/src/libtracker-db/tracker-db-manager.c

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	Mon Jun  9 15:17:36 2008
@@ -127,6 +127,7 @@
 						gboolean            attach_all);
 
 static gboolean      initialized;
+static gboolean      attach_all;
 static GHashTable   *prepared_queries;
 static gchar        *services_dir;
 static gchar        *sql_dir;
@@ -151,8 +152,7 @@
 }
 
 void 
-set_up_databases (gboolean     attach_all,
-		  const gchar *data_dir,
+set_up_databases (const gchar *data_dir,
 		  const gchar *user_data_dir,
 		  const gchar *sys_tmp_root_dir)
 {
@@ -169,7 +169,6 @@
                                              sys_tmp_root_dir);
                 
                 dbs[i].abs_filename = g_build_filename (dir, dbs[i].file, NULL);
-		dbs[i].iface = db_interface_create (i, attach_all);
         }
 
 	g_message ("Setting up all databases completed");
@@ -1803,7 +1802,7 @@
 }
 
 static TrackerDBInterface *
-db_interface_create (TrackerDB db, 
+db_interface_create (TrackerDB db,
 		     gboolean  attach_all)
 {
 	switch (db) {
@@ -1889,6 +1888,7 @@
 		return;
 	}
 
+	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
@@ -1920,8 +1920,7 @@
 	load_prepared_queries ();
 
 	/* Configure database locations and interfaces */
-	set_up_databases (attach_all_dbs, 
-			  data_dir, 
+	set_up_databases (data_dir, 
 			  user_data_dir, 
 			  sys_tmp_dir);
 
@@ -1943,8 +1942,10 @@
                         g_free (dbs[i].abs_filename);
 			dbs[i].abs_filename = NULL;
 
-			g_object_unref (dbs[i].iface);
-			dbs[i].iface = NULL;
+			if (dbs[i].iface) {
+				g_object_unref (dbs[i].iface);
+				dbs[i].iface = NULL;
+			}
                 }
         }
 
@@ -1978,6 +1979,10 @@
 TrackerDBInterface *
 tracker_db_manager_get_db_interface (TrackerDB db)
 {
+	if (!dbs[db].iface) {
+		dbs[db].iface = db_interface_create (db, attach_all);
+	}
+
 	return dbs[db].iface;
 }
 
@@ -2026,9 +2031,9 @@
 		}
 
 		if (i == TRACKER_DB_FILE_METADATA) { 
-			return dbs[TRACKER_DB_FILE_CONTENTS].iface;
+			return tracker_db_manager_get_db_interface (TRACKER_DB_FILE_CONTENTS);
 		} else if (i == TRACKER_DB_EMAIL_METADATA) { 
-			return dbs[TRACKER_DB_EMAIL_CONTENTS].iface;
+			return tracker_db_manager_get_db_interface (TRACKER_DB_EMAIL_CONTENTS);
 		}
 	}	
 



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