tracker r2636 - in branches/turtle: . src/trackerd



Author: ifrade
Date: Tue Dec  2 13:41:26 2008
New Revision: 2636
URL: http://svn.gnome.org/viewvc/tracker?rev=2636&view=rev

Log:
Dynamic turtle filename. _init and _shutdown of turtle module in the main secuence

Modified:
   branches/turtle/ChangeLog
   branches/turtle/src/trackerd/tracker-backup.c
   branches/turtle/src/trackerd/tracker-backup.h
   branches/turtle/src/trackerd/tracker-main.c

Modified: branches/turtle/src/trackerd/tracker-backup.c
==============================================================================
--- branches/turtle/src/trackerd/tracker-backup.c	(original)
+++ branches/turtle/src/trackerd/tracker-backup.c	Tue Dec  2 13:41:26 2008
@@ -30,27 +30,16 @@
 #include <raptor.h>
 #endif
 
-/* TODO (obviously) */
-#define TODO_TEMPORARY_LOCATION "/tmp/tracker-saving-things.ttl"
-
 /*
  * (uri, metadataid, value)
  */
 static void
-extended_result_set_to_turtle (TrackerDBResultSet  *result_set)
+extended_result_set_to_turtle (TrackerDBResultSet  *result_set, TurtleFile *turtle_file)
 {
 	TrackerField        *field;
 	gint	             metadata_id;
 	gboolean             valid = TRUE;
 	TrackerDataMetadata *metadata;
-	TurtleFile          *turtle_file;
-
-	/* TODO: temporary location */
-	if (g_file_test (TODO_TEMPORARY_LOCATION, G_FILE_TEST_EXISTS)) {
-		g_unlink (TODO_TEMPORARY_LOCATION);
-	}
-
-	turtle_file = tracker_turtle_open (TODO_TEMPORARY_LOCATION);
 
 	while (valid) {
 		GValue transform = {0, };
@@ -84,17 +73,22 @@
 		valid = tracker_db_result_set_iter_next (result_set);
 	}
 
-	tracker_turtle_close (turtle_file);
 }
 
 
 void 
-tracker_backup_save ()
+tracker_backup_save (const gchar *turtle_filename)
 {
 	TrackerDBResultSet *data;
 	TrackerService     *service;
+	TurtleFile          *turtle_file;
+
+	/* TODO: temporary location */
+	if (g_file_test (turtle_filename, G_FILE_TEST_EXISTS)) {
+		g_unlink (turtle_filename);
+	}
 
-	tracker_turtle_init ();
+	turtle_file = tracker_turtle_open (turtle_filename);
 
 	g_message ("***** tracker_backup: Saving metadata in turtle file *****");
 
@@ -102,8 +96,10 @@
 	data = tracker_data_query_backup_metadata (service);
 
 	if (data) {
-		extended_result_set_to_turtle (data);
+		extended_result_set_to_turtle (data, turtle_file);
 		g_object_unref (data);
 	}
+
+	tracker_turtle_close (turtle_file);
 }
 

Modified: branches/turtle/src/trackerd/tracker-backup.h
==============================================================================
--- branches/turtle/src/trackerd/tracker-backup.h	(original)
+++ branches/turtle/src/trackerd/tracker-backup.h	Tue Dec  2 13:41:26 2008
@@ -23,6 +23,6 @@
 
 #include <glib.h>
 
-void tracker_backup_save (void);
+void tracker_backup_save (const gchar *turtle_filename);
 
 #endif /* __TRACKER_BACKUP_H__ */

Modified: branches/turtle/src/trackerd/tracker-main.c
==============================================================================
--- branches/turtle/src/trackerd/tracker-main.c	(original)
+++ branches/turtle/src/trackerd/tracker-main.c	Tue Dec  2 13:41:26 2008
@@ -747,6 +747,23 @@
 	return FALSE;
 }
 
+static gchar *
+get_turtle_userdata_backup_filename () 
+{
+	TrackerMainPrivate *private;
+
+	private = g_static_private_get (&private_key);
+	
+	if (private) {
+		return g_build_filename (private->user_data_dir, 
+					 "tracker-userdata-backup.ttl",
+					 NULL);
+	} else {
+		g_critical ("Directories not initialized");
+		return NULL;
+	}
+}
+
 
 /*
  * TODO: Ugly hack counting signals because the indexer is sending two "Finished" signals
@@ -757,6 +774,7 @@
 {
 	gulong *callback_id = (gulong *)user_data;
 	GError *error;
+	gchar  *turtle_file;
 	static gint counter = 0;
 	
 	counter += 1;
@@ -764,9 +782,12 @@
 	if (counter >= 2) {
 		g_debug ("Uninstalling initial crawling callback");
 		g_signal_handler_disconnect (processor, *callback_id);
+
+		turtle_file = get_turtle_userdata_backup_filename ();
 		org_freedesktop_Tracker_Indexer_restore_backup (tracker_dbus_indexer_get_proxy (), 
-								"/tmp/tracker-saving-things.ttl",
+								turtle_file,
 								&error);
+		g_free (turtle_file);
 	} else {
 		g_debug ("%d finished signal", counter);
 	}
@@ -939,13 +960,20 @@
 		return EXIT_FAILURE;
 	}
 
+	tracker_turtle_init ();
+
 	tracker_module_config_init ();
 
 	flags |= TRACKER_DB_MANAGER_REMOVE_CACHE;
 	index_flags |= TRACKER_DB_INDEX_MANAGER_READONLY;
 
 	if (force_reindex) {
-		g_message ("***** Saving metadata in turtle file *****");
+
+		gchar              *turtle_file;
+
+		turtle_file = get_turtle_userdata_backup_filename ();
+
+		g_message ("Saving metadata in %s", turtle_file);
 
 		/* Init the DB stack */
 		tracker_db_manager_init (0, &is_first_time_index, TRUE);
@@ -959,14 +987,16 @@
 		
 		tracker_data_manager_init (config, language, file_index, email_index);
 		
-		tracker_backup_save ();
+		tracker_backup_save (turtle_file);
 
 		/* Shutdown the DB stack */
 		tracker_data_manager_shutdown ();
 		
 		tracker_db_index_manager_shutdown ();
 		tracker_db_manager_shutdown ();
-		
+
+		g_free (turtle_file);
+
 		flags |= TRACKER_DB_MANAGER_FORCE_REINDEX;
 		index_flags |= TRACKER_DB_INDEX_MANAGER_FORCE_REINDEX;
 	}
@@ -1135,6 +1165,7 @@
 	tracker_module_config_shutdown ();
 	tracker_nfs_lock_shutdown ();
 	tracker_status_shutdown ();
+	tracker_turtle_shutdown ();
 	tracker_log_shutdown ();
 
 #ifdef HAVE_HAL



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