[tracker/miner-userguide] fixup: Added better logging for locale detection



commit 9e8e3bae292d43f27efbaf44d7e0b2d55eda2a41
Author: Martyn Russell <martyn lanedo com>
Date:   Thu Nov 24 13:11:50 2011 +0000

    fixup: Added better logging for locale detection

 src/miners/fs/tracker-miner-userguides.c |   37 +++++++++++++-----------------
 1 files changed, 16 insertions(+), 21 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-userguides.c b/src/miners/fs/tracker-miner-userguides.c
index ccb406b..7cdc57e 100644
--- a/src/miners/fs/tracker-miner-userguides.c
+++ b/src/miners/fs/tracker-miner-userguides.c
@@ -124,7 +124,7 @@ miner_userguides_basedir_add (TrackerMinerFS *fs,
 {
 	GFile *file;
 	gchar *path;
-	gboolean index_all_locales = TRUE;
+	gint added = 0;
 
 	/* Without MeeGoTouch, we simply index ALL content. */
 #ifdef HAVE_MEEGOTOUCH
@@ -134,43 +134,38 @@ miner_userguides_basedir_add (TrackerMinerFS *fs,
 	if (locale) {
 		/* First we try the "xx_YY" of the current locale */
 		path = g_build_filename (basedir, "userguide", "contents", locale, NULL);
-		file = g_file_new_for_path (path);
 
 		if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
 			g_message ("  Adding:'%s'", path);
+			file = g_file_new_for_path (path);
 			tracker_miner_fs_directory_add (fs, file, TRUE);
 			g_object_unref (file);
-			g_free (path);
 
-			index_all_locales = FALSE;
-		} else {
-			gchar *short_locale;
-
-			g_object_unref (file);
+			added++;
+		} else if (strlen (locale) > 2) {
+			/* Clean up */
+			g_message ("  Did not find userguide yet matching locale:'%s'", locale);
 			g_free (path);
 
 			/* Second we try the "xx" of the current locale */
-			short_locale = g_strdup_printf ("%2.2s", locale);
+			locale[2] = '\0';
 			path = g_build_filename (basedir, "userguide", "contents", short_locale, NULL);
-			file = g_file_new_for_path (path);
 
 			if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
 				g_message ("  Adding:'%s'", path);
+				file = g_file_new_for_path (path);
 				tracker_miner_fs_directory_add (fs, file, TRUE);
 				g_object_unref (file);
-				g_free (path);
 
-				index_all_locales = FALSE;
-			} else {
-				g_object_unref (file);
-				g_free (path);
-
-				g_warning ("Could not find a userguide matching the locale:'%s' or '%s'",
-				           locale,
-				           short_locale);
+				added++;
 			}
+		}
+
+		/* Clean up */
+		g_free (path);
 
-			g_free (short_locale);
+		if (added < 1) {
+			g_message ("  Did not find userguide yet matching locale:'%s' (either)", locale);
 		}
 
 		g_free (locale);
@@ -179,7 +174,7 @@ miner_userguides_basedir_add (TrackerMinerFS *fs,
 	}
 #endif /* HAVE_MEEGOTOUCH */
 
-	if (index_all_locales) {
+	if (added < 1) {
 		/* Add $dir/userguide/contents */
 		path = g_build_filename (basedir, "userguide", "contents", NULL);
 		file = g_file_new_for_path (path);



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