[tracker/ontology-cope] squashme, refactor



commit 0f68b4c108f1cf73584f7ea547b09c3bbdad7d16
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Feb 16 18:16:35 2010 +0100

    squashme, refactor

 src/libtracker-data/tracker-data-manager.c |   87 +++++++++++----------------
 1 files changed, 36 insertions(+), 51 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index e67bd7c..bdbfb4c 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -1103,6 +1103,40 @@ import_ontology_into_db (void)
 	}
 }
 
+static GList*
+get_ontologies (gboolean test_schema, const gchar *ontologies_dir)
+{
+	GList *sorted = NULL;
+
+	if (test_schema) {
+		sorted = g_list_prepend (sorted, g_strdup ("12-nrl.ontology"));
+		sorted = g_list_prepend (sorted, g_strdup ("11-rdf.ontology"));
+		sorted = g_list_prepend (sorted, g_strdup ("10-xsd.ontology"));
+	} else {
+		GDir        *ontologies;
+		const gchar *conf_file;
+
+		ontologies = g_dir_open (ontologies_dir, 0, NULL);
+
+		conf_file = g_dir_read_name (ontologies);
+
+		/* .ontology files */
+		while (conf_file) {
+			if (g_str_has_suffix (conf_file, ".ontology")) {
+				sorted = g_list_insert_sorted (sorted,
+				                               g_strdup (conf_file),
+				                               (GCompareFunc) strcmp);
+			}
+			conf_file = g_dir_read_name (ontologies);
+		}
+
+		g_dir_close (ontologies);
+	}
+
+	return sorted;
+}
+
+
 gboolean
 tracker_data_manager_init (TrackerDBManagerFlags  flags,
                            const gchar           *test_schema,
@@ -1182,33 +1216,7 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 		GError *error = NULL;
 		gchar *test_schema_path = NULL;
 
-		if (test_schema) {
-			/* load test schema, not used in normal operation */
-			test_schema_path = g_strconcat (test_schema, ".ontology", NULL);
-
-			sorted = g_list_prepend (sorted, g_strdup ("12-nrl.ontology"));
-			sorted = g_list_prepend (sorted, g_strdup ("11-rdf.ontology"));
-			sorted = g_list_prepend (sorted, g_strdup ("10-xsd.ontology"));
-		} else {
-			GDir        *ontologies;
-			const gchar *conf_file;
-
-			ontologies = g_dir_open (ontologies_dir, 0, NULL);
-
-			conf_file = g_dir_read_name (ontologies);
-
-			/* .ontology files */
-			while (conf_file) {
-				if (g_str_has_suffix (conf_file, ".ontology")) {
-					sorted = g_list_insert_sorted (sorted,
-					                               g_strdup (conf_file),
-					                               (GCompareFunc) strcmp);
-				}
-				conf_file = g_dir_read_name (ontologies);
-			}
-
-			g_dir_close (ontologies);
-		}
+		sorted = get_ontologies (test_schema != NULL, ontologies_dir);
 
 		tracker_db_journal_init (NULL);
 
@@ -1260,30 +1268,7 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 	}
 
 	if (check_ontology) {
-		if (test_schema) {
-			sorted = g_list_prepend (sorted, g_strdup ("12-nrl.ontology"));
-			sorted = g_list_prepend (sorted, g_strdup ("11-rdf.ontology"));
-			sorted = g_list_prepend (sorted, g_strdup ("10-xsd.ontology"));
-		} else {
-			GDir        *ontologies;
-			const gchar *conf_file;
-
-			ontologies = g_dir_open (ontologies_dir, 0, NULL);
-
-			conf_file = g_dir_read_name (ontologies);
-
-			/* .ontology files */
-			while (conf_file) {
-				if (g_str_has_suffix (conf_file, ".ontology")) {
-					sorted = g_list_insert_sorted (sorted,
-					                               g_strdup (conf_file),
-					                               (GCompareFunc) strcmp);
-				}
-				conf_file = g_dir_read_name (ontologies);
-			}
-
-			g_dir_close (ontologies);
-		}
+		sorted = get_ontologies (test_schema != NULL, ontologies_dir);
 
 		/* check ontology against database */
 		tracker_data_begin_transaction ();



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