[tracker/tracker-0.8-with-ontology-cope-and-miner-fs-index: 8/17] libtracker-data: Bugfix coping with property ontology changes



commit 3fcec76546615ead03db9e0a78408cfecaa2d9bc
Author: Philip Van Hoof <philip codeminded be>
Date:   Wed Apr 7 11:38:16 2010 +0200

    libtracker-data: Bugfix coping with property ontology changes

 src/libtracker-data/tracker-data-manager.c  |  116 ++++++++++++++------------
 tests/libtracker-data/tracker-backup-test.c |    8 +--
 2 files changed, 64 insertions(+), 60 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index de54443..a33ea9f 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -199,8 +199,6 @@ update_property_value (const gchar *kind,
 
 	result_set = tracker_data_query_sparql (query, &error);
 
-	g_free (query);
-
 	if (!error && result_set) {
 		gchar *str = NULL;
 
@@ -221,6 +219,8 @@ update_property_value (const gchar *kind,
 		}
 
 		g_free (str);
+	} else {
+		needed = (g_strcmp0 (object, "true") == 0);
 	}
 
 	if (result_set) {
@@ -240,6 +240,8 @@ update_property_value (const gchar *kind,
 		g_clear_error (&error);
 	}
 
+	g_free (query);
+
 	return needed;
 }
 
@@ -663,63 +665,67 @@ tracker_data_ontology_post_check (GPtrArray *seen_classes,
 	 * For example when going from: prefix:A rdfs:Class ; tracker:notify true .
 	 * to prefix:A rdfs:Class . */
 
-	for (i = 0; i < seen_classes->len; i++) {
-		TrackerClass *class = g_ptr_array_index (seen_classes, i);
-		const gchar *subject;
-		subject = tracker_class_get_uri (class);
-		if (tracker_class_get_notify (class)) {
-			update_property_value ("tracker:notify",
-			                       subject,
-			                       TRACKER_PREFIX "notify",
-			                       "true", allowed_boolean_conversions);
-		} else {
-			update_property_value ("tracker:notify",
-			                       subject,
-			                       TRACKER_PREFIX "notify",
-			                       "false", allowed_boolean_conversions);
+	if (seen_classes) {
+		for (i = 0; i < seen_classes->len; i++) {
+			TrackerClass *class = g_ptr_array_index (seen_classes, i);
+			const gchar *subject;
+			subject = tracker_class_get_uri (class);
+			if (tracker_class_get_notify (class)) {
+				update_property_value ("tracker:notify",
+				                       subject,
+				                       TRACKER_PREFIX "notify",
+				                       "true", allowed_boolean_conversions);
+			} else {
+				update_property_value ("tracker:notify",
+				                       subject,
+				                       TRACKER_PREFIX "notify",
+				                       "false", allowed_boolean_conversions);
+			}
 		}
 	}
 
-	for (i = 0; i < seen_properties->len; i++) {
-		TrackerProperty *property = g_ptr_array_index (seen_properties, i);
-		const gchar *subject;
-		subject = tracker_property_get_uri (property);
-		if (tracker_property_get_writeback (property)) {
-			update_property_value ("tracker:writeback",
-			                       subject,
-			                       TRACKER_PREFIX "writeback",
-			                       "true", allowed_boolean_conversions);
-		} else {
-			update_property_value ("tracker:writeback",
-			                       subject,
-			                       TRACKER_PREFIX "writeback",
-			                       "false", allowed_boolean_conversions);
-		}
-
-		if (tracker_property_get_indexed (property)) {
-			if (update_property_value ("tracker:indexed",
-			                           subject,
-			                           TRACKER_PREFIX "indexed",
-			                           "true", allowed_boolean_conversions)) {
-				fix_indexed (property, TRUE);
+	if (seen_properties) {
+		for (i = 0; i < seen_properties->len; i++) {
+			TrackerProperty *property = g_ptr_array_index (seen_properties, i);
+			const gchar *subject;
+			subject = tracker_property_get_uri (property);
+			if (tracker_property_get_writeback (property)) {
+				update_property_value ("tracker:writeback",
+				                       subject,
+				                       TRACKER_PREFIX "writeback",
+				                       "true", allowed_boolean_conversions);
+			} else {
+				update_property_value ("tracker:writeback",
+				                       subject,
+				                       TRACKER_PREFIX "writeback",
+				                       "false", allowed_boolean_conversions);
 			}
-		} else {
-			if (update_property_value ("tracker:indexed",
-			                           subject,
-			                           TRACKER_PREFIX "indexed",
-			                           "false", allowed_boolean_conversions)) {
-				fix_indexed (property, FALSE);
+
+			if (tracker_property_get_indexed (property)) {
+				if (update_property_value ("tracker:indexed",
+				                           subject,
+				                           TRACKER_PREFIX "indexed",
+				                           "true", allowed_boolean_conversions)) {
+					fix_indexed (property, TRUE);
+				}
+			} else {
+				if (update_property_value ("tracker:indexed",
+				                           subject,
+				                           TRACKER_PREFIX "indexed",
+				                           "false", allowed_boolean_conversions)) {
+					fix_indexed (property, FALSE);
+				}
 			}
-		}
 
-		if (update_property_value ("rdfs:range", subject, RDFS_PREFIX "range",
-		                           tracker_class_get_uri (tracker_property_get_range (property)), 
-		                           allowed_range_conversions)) {
-			TrackerClass *class;
+			if (update_property_value ("rdfs:range", subject, RDFS_PREFIX "range",
+			                           tracker_class_get_uri (tracker_property_get_range (property)), 
+			                           allowed_range_conversions)) {
+				TrackerClass *class;
 
-			class = tracker_property_get_domain (property);
-			tracker_class_set_need_recreate (class, TRUE);
-			tracker_property_set_need_recreate (property, TRUE);
+				class = tracker_property_get_domain (property);
+				tracker_class_set_need_recreate (class, TRUE);
+				tracker_property_set_need_recreate (property, TRUE);
+			}
 		}
 	}
 }
@@ -727,8 +733,10 @@ tracker_data_ontology_post_check (GPtrArray *seen_classes,
 void
 tracker_data_ontology_free_seen (GPtrArray *seen)
 {
-	g_ptr_array_foreach (seen, (GFunc) g_object_unref, NULL);
-	g_ptr_array_free (seen, TRUE);
+	if (seen) {
+		g_ptr_array_foreach (seen, (GFunc) g_object_unref, NULL);
+		g_ptr_array_free (seen, TRUE);
+	}
 }
 
 static void
diff --git a/tests/libtracker-data/tracker-backup-test.c b/tests/libtracker-data/tracker-backup-test.c
index 2ff1568..d5e3a2a 100644
--- a/tests/libtracker-data/tracker-backup-test.c
+++ b/tests/libtracker-data/tracker-backup-test.c
@@ -209,12 +209,8 @@ main (int argc, char **argv)
 
 	g_free (current_dir);
 
-// Inexplicable error happens with this enabled:
-// Tracker-CRITICAL **: Subject `http://www.w3.org/2001/XMLSchema#string' is not in domain `rdfs:Class' of property `tracker:notify'
-// I have no idea atm :-\
-
-//	g_test_add_func ("/tracker/libtracker-data/backup/journal_then_save_and_restore",
-//	                 test_journal_then_backup_and_restore);
+	g_test_add_func ("/tracker/libtracker-data/backup/journal_then_save_and_restore",
+	                 test_journal_then_backup_and_restore);
 
 	g_test_add_func ("/tracker/libtracker-data/backup/save_and_restore",
 	                 test_backup_and_restore);



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