tracker r3123 - in trunk: . src/libtracker-db



Author: mr
Date: Mon Mar 23 17:13:38 2009
New Revision: 3123
URL: http://svn.gnome.org/viewvc/tracker?rev=3123&view=rev

Log:


Modified:
   trunk/ChangeLog
   trunk/src/libtracker-db/tracker-db-index-manager.c
   trunk/src/libtracker-db/tracker-db-index-manager.h
   trunk/src/libtracker-db/tracker-db-manager.c
   trunk/src/libtracker-db/tracker-db-manager.h

Modified: trunk/src/libtracker-db/tracker-db-index-manager.c
==============================================================================
--- trunk/src/libtracker-db/tracker-db-index-manager.c	(original)
+++ trunk/src/libtracker-db/tracker-db-index-manager.c	Mon Mar 23 17:13:38 2009
@@ -138,9 +138,9 @@
 }
 
 gboolean
-tracker_db_index_manager_init (TrackerDBIndexManagerFlags  flags,
-			       gint			   min_bucket,
-			       gint			   max_bucket)
+tracker_db_index_manager_init (TrackerDBIndexManagerFlags flags,
+			       gint			  min_bucket,
+			       gint			  max_bucket)
 {
 	gchar	 *final_index_filename;
 	gchar	 *name;
@@ -180,6 +180,14 @@
 		}
 	}
 
+	/* If we are just initializing to remove the databases,
+	 * return here. 
+	 */
+	if ((flags & TRACKER_DB_INDEX_MANAGER_REMOVE_ALL) != 0) {
+		initialized = TRUE;
+		return TRUE;
+	}
+
 	g_message ("Merging old temporary indexes");
 
 	i = TRACKER_DB_INDEX_FILE;
@@ -254,8 +262,10 @@
 	}
 
 	for (i = 1; i < G_N_ELEMENTS (indexes); i++) {
-		g_object_unref (indexes[i].index);
-		indexes[i].index = NULL;
+		if (indexes[i].index) {
+			g_object_unref (indexes[i].index);
+			indexes[i].index = NULL;
+		}
 
 		g_free (indexes[i].abs_filename);
 		indexes[i].abs_filename = NULL;
@@ -266,6 +276,23 @@
 	initialized = FALSE;
 }
 
+void
+tracker_db_index_manager_remove_all (void)
+{
+	guint i;
+
+	g_message ("Removing all database index files");
+
+	/* NOTE: We don't have to be initialized for this so we
+	 * calculate the absolute directories here. 
+	 */
+	for (i = 1; i < G_N_ELEMENTS (indexes); i++) {
+		g_message ("  Removing database index:'%s'",
+			   indexes[i].abs_filename);
+		g_unlink (indexes[i].abs_filename);
+	}
+}
+
 TrackerDBIndex *
 tracker_db_index_manager_get_index (TrackerDBIndexType type)
 {

Modified: trunk/src/libtracker-db/tracker-db-index-manager.h
==============================================================================
--- trunk/src/libtracker-db/tracker-db-index-manager.h	(original)
+++ trunk/src/libtracker-db/tracker-db-index-manager.h	Mon Mar 23 17:13:38 2009
@@ -37,13 +37,15 @@
 
 typedef enum {
 	TRACKER_DB_INDEX_MANAGER_FORCE_REINDEX = 1 << 1,
-	TRACKER_DB_INDEX_MANAGER_READONLY      = 1 << 2
+	TRACKER_DB_INDEX_MANAGER_READONLY      = 1 << 2,
+	TRACKER_DB_INDEX_MANAGER_REMOVE_ALL    = 1 << 3
 } TrackerDBIndexManagerFlags;
 
 gboolean	tracker_db_index_manager_init			 (TrackerDBIndexManagerFlags  flags,
 								  gint			      min_bucket,
 								  gint			      max_bucket);
 void		tracker_db_index_manager_shutdown		 (void);
+void            tracker_db_index_manager_remove_all              (void);
 TrackerDBIndex *tracker_db_index_manager_get_index		 (TrackerDBIndexType	      index);
 TrackerDBIndex *tracker_db_index_manager_get_index_by_service	 (const gchar		     *service);
 TrackerDBIndex *tracker_db_index_manager_get_index_by_service_id (gint			      id);

Modified: trunk/src/libtracker-db/tracker-db-manager.c
==============================================================================
--- trunk/src/libtracker-db/tracker-db-manager.c	(original)
+++ trunk/src/libtracker-db/tracker-db-manager.c	Mon Mar 23 17:13:38 2009
@@ -1787,8 +1787,11 @@
 
 	g_message ("Removing all database files");
 
+	/* NOTE: We don't have to be initialized for this so we
+	 * calculate the absolute directories here. 
+	 */
 	for (i = 1; i < G_N_ELEMENTS (dbs); i++) {
-		g_message ("Removing database:'%s'",
+		g_message ("  Removing database:'%s'",
 			   dbs[i].abs_filename);
 		g_unlink (dbs[i].abs_filename);
 	}
@@ -2054,6 +2057,14 @@
 		}
 	}
 
+	/* If we are just initializing to remove the databases,
+	 * return here. 
+	 */
+	if ((flags & TRACKER_DB_MANAGER_REMOVE_ALL) != 0) {
+		initialized = TRUE;
+		return;
+	}
+
 	/* Set general database options */
 	if (shared_cache) {
 		g_message ("Enabling database shared cache");
@@ -2157,8 +2168,10 @@
 		}
 	}
 
-	g_hash_table_unref (prepared_queries);
-	prepared_queries = NULL;
+	if (prepared_queries) {
+		g_hash_table_unref (prepared_queries);
+		prepared_queries = NULL;
+	}
 
 	g_free (data_dir);
 	g_free (user_data_dir);
@@ -2199,7 +2212,7 @@
 tracker_db_manager_remove_all (void)
 {
 	g_return_if_fail (initialized != FALSE);
-
+	
 	db_manager_remove_all ();
 }
 

Modified: trunk/src/libtracker-db/tracker-db-manager.h
==============================================================================
--- trunk/src/libtracker-db/tracker-db-manager.h	(original)
+++ trunk/src/libtracker-db/tracker-db-manager.h	Mon Mar 23 17:13:38 2009
@@ -51,6 +51,7 @@
 	TRACKER_DB_MANAGER_FORCE_REINDEX    = 1 << 1,
 	TRACKER_DB_MANAGER_REMOVE_CACHE     = 1 << 2,
 	TRACKER_DB_MANAGER_LOW_MEMORY_MODE  = 1 << 3,
+	TRACKER_DB_MANAGER_REMOVE_ALL       = 1 << 4
 } TrackerDBManagerFlags;
 
 #define TRACKER_DB_FOR_FILE_SERVICE	"Files"



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