tracker r1179 - trunk/src/trackerd



Author: jamiemcc
Date: Fri Feb 29 05:05:09 2008
New Revision: 1179
URL: http://svn.gnome.org/viewvc/tracker?rev=1179&view=rev

Log:
make sure final file is moved to index file if it exists and no tmp merge indexes are present

Modified:
   trunk/src/trackerd/tracker-indexer.c
   trunk/src/trackerd/tracker-indexer.h
   trunk/src/trackerd/trackerd.c

Modified: trunk/src/trackerd/tracker-indexer.c
==============================================================================
--- trunk/src/trackerd/tracker-indexer.c	(original)
+++ trunk/src/trackerd/tracker-indexer.c	Fri Feb 29 05:05:09 2008
@@ -482,6 +482,31 @@
 
 }
 
+gboolean
+tracker_indexer_has_tmp_merge_files (IndexType type)
+{
+	GSList *files = NULL;
+	gboolean result = FALSE;
+
+
+	if (type == INDEX_TYPE_FILES) {
+		files =  tracker_get_files_with_prefix (tracker->data_dir, "file-index.tmp.");
+	} else {
+		files =  tracker_get_files_with_prefix (tracker->data_dir, "email-index.tmp.");
+	}
+
+	result = (files != NULL);
+
+	if (result) {
+		g_slist_foreach (files, (GFunc) g_free, NULL);
+		g_slist_free (files);
+	}
+
+	return result;
+
+}
+
+
 
 gboolean
 tracker_indexer_has_merge_files (IndexType type)

Modified: trunk/src/trackerd/tracker-indexer.h
==============================================================================
--- trunk/src/trackerd/tracker-indexer.h	(original)
+++ trunk/src/trackerd/tracker-indexer.h	Fri Feb 29 05:05:09 2008
@@ -105,6 +105,7 @@
 void		tracker_indexer_free 			(Indexer *indexer, gboolean remove_file);
 gboolean	tracker_indexer_has_merge_index 	(Indexer *indexer, gboolean update);
 
+
 guint32		tracker_indexer_size 			(Indexer *indexer);
 gboolean	tracker_indexer_optimize		(Indexer *indexer);
 void		tracker_indexer_sync 			(Indexer *indexer);
@@ -112,6 +113,7 @@
 void		tracker_indexer_apply_changes 		(Indexer *dest, Indexer *src,  gboolean update);
 void		tracker_indexer_merge_indexes 		(IndexType type);
 gboolean	tracker_indexer_has_merge_files 	(IndexType type);
+gboolean	tracker_indexer_has_tmp_merge_files 	(IndexType type);
 
 /* Indexing api */
 gboolean	tracker_indexer_append_word 		(Indexer *indexer, const gchar *word, guint32 id, gint service, gint score);

Modified: trunk/src/trackerd/trackerd.c
==============================================================================
--- trunk/src/trackerd/trackerd.c	(original)
+++ trunk/src/trackerd/trackerd.c	Fri Feb 29 05:05:09 2008
@@ -2878,6 +2878,39 @@
 	db_con->index = db_con;
 
 	main_thread_db_con = db_con;
+	
+	/* move final file to index file if present and no files left to merge */
+	char *final_index_name = g_build_filename (tracker->data_dir, "file-index-final", NULL);
+	
+	if (g_file_test (final_index_name, G_FILE_TEST_EXISTS) && !tracker_indexer_has_tmp_merge_files (INDEX_TYPE_FILES)) {
+	
+		char *file_index_name = g_build_filename (tracker->data_dir, "file-index.db", NULL);
+	
+		tracker_log ("overwriting %s with %s", file_index_name, final_index_name);	
+
+		rename (final_index_name, file_index_name);
+		
+		g_free (file_index_name);
+	}
+	
+	g_free (final_index_name);
+	
+	final_index_name = g_build_filename (tracker->data_dir, "email-index-final", NULL);
+	
+	if (g_file_test (final_index_name, G_FILE_TEST_EXISTS) && !tracker_indexer_has_tmp_merge_files (INDEX_TYPE_EMAILS)) {
+	
+		char *file_index_name = g_build_filename (tracker->data_dir, "email-index.db", NULL);
+	
+		tracker_log ("overwriting %s with %s", file_index_name, final_index_name);	
+	
+		rename (final_index_name, file_index_name);
+		
+		g_free (file_index_name);
+	}
+	
+	g_free (final_index_name);
+	
+	
 
 	Indexer *index = tracker_indexer_open ("file-index.db");
 	index->main_index = TRUE;



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