tracker r1644 - in branches/indexer-split: . src/tracker-indexer src/trackerd



Author: mr
Date: Wed Jun 11 16:08:51 2008
New Revision: 1644
URL: http://svn.gnome.org/viewvc/tracker?rev=1644&view=rev

Log:
	* src/tracker-indexer/tracker-main.c: Removed commented out code.

	* src/trackerd/tracker-crawler.c: Renamed internal functions
	better and fixed a nasty crasher because we weren't NULL
	terminating the GStrv we send to the indexer to process.

	* src/trackerd/tracker-main.c: Don't initiate and shutdown the
	process-files module, it is no longer used. Also make sure we
	shutdown properly when using Ctrl+C. Now when we initiate the db
	manager we set the attach_all to TRUE now that Carlos has fixed
	that bug. This means we use one connection for all transactions in
	the daemon now.


Modified:
   branches/indexer-split/ChangeLog
   branches/indexer-split/src/tracker-indexer/tracker-main.c
   branches/indexer-split/src/trackerd/tracker-crawler.c
   branches/indexer-split/src/trackerd/tracker-main.c

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	Wed Jun 11 16:08:51 2008
@@ -86,6 +86,7 @@
 	case SIGSEGV:
 		/* we are screwed if we get this so exit immediately! */
 		exit (EXIT_FAILURE);
+
 	case SIGBUS:
 	case SIGILL:
 	case SIGFPE:
@@ -96,15 +97,6 @@
 		in_loop = TRUE;
 		g_main_loop_quit (main_loop);
 
-		/*
-		tracker->is_running = FALSE;
-		tracker_end_watching ();
-
-		g_timeout_add_full (G_PRIORITY_LOW,
-				    1,
-				    (GSourceFunc) tracker_do_cleanup,
-				    g_strdup (g_strsignal (signo)), NULL);
-		*/
 	default:
 		if (g_strsignal (signo)) {
 			g_warning ("Received signal: %s", g_strsignal (signo));

Modified: branches/indexer-split/src/trackerd/tracker-crawler.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-crawler.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-crawler.c	Wed Jun 11 16:08:51 2008
@@ -54,7 +54,7 @@
 	gchar         **ignored_suffixes;
 	gchar         **ignored_prefixes;
 
-	guint           dirs_in_progress;
+	guint           enumerations;
 	guint           files_found; 
 	guint           files_ignored; 
 	
@@ -86,10 +86,8 @@
 					    gpointer        user_data);
 #endif /* HAVE_HAL */
 
-static void crawl_directory                (TrackerCrawler *crawler,
-					    const gchar    *path);
-static void crawl_directory_known_to_exist (TrackerCrawler *crawler,
-					    GFile          *file);
+static void file_enumerate (TrackerCrawler *crawler,
+			    GFile          *file);
 
 G_DEFINE_TYPE(TrackerCrawler, tracker_crawler, G_TYPE_OBJECT)
 
@@ -517,13 +515,13 @@
 }
 
 static void
-dirs_crawling_increment (TrackerCrawler *crawler)
+file_enumerators_increment (TrackerCrawler *crawler)
 {
 	TrackerCrawlerPriv *priv;
 
 	priv = crawler->priv;
 
-	if (priv->dirs_in_progress == 0) {
+	if (priv->enumerations == 0) {
 		g_message ("Starting to crawl file system...");
 
 		if (!priv->timer) {
@@ -536,19 +534,19 @@
 		priv->files_ignored = 0;
 	}
 
-	priv->dirs_in_progress++;
+	priv->enumerations++;
 }
 
 static void
-dirs_crawling_decrement (TrackerCrawler *crawler)
+file_enumerators_decrement (TrackerCrawler *crawler)
 {
 	TrackerCrawlerPriv *priv;
 
 	priv = crawler->priv;
 
-	priv->dirs_in_progress--;
+	priv->enumerations--;
 
-	if (priv->dirs_in_progress == 0) {
+	if (priv->enumerations == 0) {
 		g_timer_stop (priv->timer);
 
 		g_message ("%s crawling files in %4.4f seconds, %d found, %d ignored", 
@@ -556,13 +554,15 @@
 			   g_timer_elapsed (priv->timer, NULL),
 			   priv->files_found,
 			   priv->files_ignored);
+
+		priv->running = FALSE;
 	}
 }
 
 static void
-crawl_directory_cb (GObject      *file,
-		    GAsyncResult *res,
-		    gpointer      user_data)
+file_enumerate_cb (GObject      *file,
+		   GAsyncResult *res,
+		   gpointer      user_data)
 {
 	TrackerCrawler  *crawler;
 	GMainContext    *context;
@@ -576,7 +576,7 @@
 	enumerator = g_file_enumerate_children_finish (parent, res, NULL);
 
 	if (!enumerator) {
-		dirs_crawling_decrement (crawler);
+		file_enumerators_decrement (crawler);
 		return;
 	}
 
@@ -590,16 +590,16 @@
 			crawler->priv->files_ignored++;
 			g_debug ("Ignored:'%s' (%d)",  
 				 relative_path, 
-				 crawler->priv->dirs_in_progress); 
+				 crawler->priv->enumerations); 
 			g_free (relative_path);
 		} else {
 			crawler->priv->files_found++;
 			g_debug ("Found  :'%s' (%d)", 
 				 relative_path, 
-				 crawler->priv->dirs_in_progress);
+				 crawler->priv->enumerations);
 
 			if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
-				crawl_directory_known_to_exist (crawler, child);
+				file_enumerate (crawler, child);
 				g_free (relative_path);
 			} else {
 				g_async_queue_push (crawler->priv->files,
@@ -620,44 +620,24 @@
 
 	g_file_enumerator_close (enumerator, NULL, NULL);
 	
-	dirs_crawling_decrement (crawler);
+	file_enumerators_decrement (crawler);
 }
 
 static void
-crawl_directory_known_to_exist (TrackerCrawler *crawler,
-				GFile          *file)
+file_enumerate (TrackerCrawler *crawler,
+		GFile          *file)
 {
-	dirs_crawling_increment (crawler);
+	file_enumerators_increment (crawler);
 
 	g_file_enumerate_children_async (file, 
 					 "*",
 					 G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
 					 G_PRIORITY_DEFAULT,
 					 NULL, 
-					 crawl_directory_cb,
+					 file_enumerate_cb,
 					 crawler);
 }
 
-static void
-crawl_directory (TrackerCrawler *crawler,
-		 const gchar    *path)
-{
-	GFile    *file;
-	gboolean  exists;
-
-	file = g_file_new_for_path (path);
-	exists = g_file_query_exists (file, NULL);
-	
-	if (exists) {
-		g_message ("Searching directory:'%s'", path);
-		crawl_directory_known_to_exist (crawler, file);
-	} else {
-		g_message ("Searching directory:'%s' failed, does not exist", path);
-	}
-
-	g_object_unref (file);
-}
-
 static gboolean
 file_queue_handle_cb (gpointer user_data)
 {
@@ -682,13 +662,12 @@
 	proxy = tracker_dbus_indexer_get_proxy ();
 	error = NULL;
 
-	g_debug ("Checking indexer is running");
 	org_freedesktop_Tracker_Indexer_get_running (proxy, 
 						     &running,
 						     &error);
 	if (error || !running) {
-		g_critical ("Couldn't process files, %s", 
-			    error ? error->message : "indexer not running");
+		g_message ("Couldn't process files, %s", 
+			   error ? error->message : "indexer not running");
 		g_clear_error (&error);
 		return TRUE;
 	}
@@ -717,6 +696,7 @@
 		}
 	}
 
+	g_ptr_array_add (ptr_array, NULL);
 	files = (gchar **) g_ptr_array_free (ptr_array, FALSE);
 
 	g_debug ("Sending %d files to indexer to process", 
@@ -744,6 +724,9 @@
 tracker_crawler_start (TrackerCrawler *crawler)
 {
 	TrackerCrawlerPriv *priv;
+	GFile              *file;
+	const gchar        *path;
+	gboolean            exists;
 
 	g_return_if_fail (TRACKER_IS_CRAWLER (crawler));
 
@@ -763,8 +746,21 @@
 		get_remote_roots (crawler, NULL, NULL);
 	}
 
-	/* crawl_directory (crawler, "/home/martyn/Documents");     */
-	crawl_directory (crawler, g_get_home_dir ());  
+	path = "/home/martyn/Documents";
+	/* path = g_get_home_dir (); */
+
+	file = g_file_new_for_path (path);
+	
+	exists = g_file_query_exists (file, NULL);
+	
+	if (exists) {
+		g_message ("Searching directory:'%s'", path);
+		file_enumerate (crawler, file);
+	} else {
+		g_message ("Searching directory:'%s' failed, does not exist", path);
+	}
+
+	g_object_unref (file);
 }
 
 void

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	Wed Jun 11 16:08:51 2008
@@ -404,7 +404,7 @@
 	case SIGTERM:
 	case SIGINT:
 		in_loop = TRUE;
-		tracker->is_running = FALSE;
+		tracker_shutdown ();
 	
 	default:
 		if (g_strsignal (signo)) {
@@ -805,7 +805,7 @@
 	tracker_nfs_lock_init (tracker_config_get_nfs_locking (tracker->config));
 	tracker_ontology_init ();
 	tracker_db_init ();
-	tracker_db_manager_init (FALSE, data_dir, user_data_dir, sys_tmp_dir); /* Using TRUE=broken */
+	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));
 
@@ -882,7 +882,6 @@
 	shutdown_directories ();
 
 	/* Shutdown major subsystems */
-	tracker_process_files_shutdown ();
 	tracker_email_end_email_watching ();
 	tracker_dbus_shutdown ();
 	tracker_xesam_manager_shutdown ();
@@ -915,6 +914,8 @@
 void
 tracker_shutdown (void)
 {
+	tracker->is_running = FALSE;
+
 	/* Stop any tight loop operations */
 	tracker_crawler_stop (tracker->crawler);
 



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