[tracker/domain-specific-indexes-review: 10/13] libtracker-data: Adapt the introspection of the ontology on domainIndex deletion



commit c1b8f48b5e3031279d80fa518072c58ac49b9bec
Author: Philip Van Hoof <philip codeminded be>
Date:   Mon Jul 5 17:19:54 2010 +0200

    libtracker-data: Adapt the introspection of the ontology on domainIndex deletion

 src/libtracker-data/tracker-data-manager.c |   36 ++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 2c86a79..213bc79 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -547,7 +547,22 @@ tracker_data_ontology_load_statement (const gchar *ontology_path,
 		property = tracker_ontologies_get_property_by_uri (object);
 
 		if (property == NULL) {
-			g_critical ("%s: Unknown property %s for tracker:domainIndex in %s",
+
+			/* In this case the import of the TTL will still make the introspection
+			 * have the URI set as a tracker:domainIndex for class. The critical
+			 * will have happened, but future operations might not cope with this
+			 * situation. TODO: add error handling so that the entire ontology
+			 * change operation is discarded, for example ignore the entire
+			 * .ontology file and rollback all changes that happened. I would
+			 * prefer a hard abort() here over a g_critical(), to be honest.
+			 *
+			 * Of course don't we yet allow just anybody to alter the ontology
+			 * files. So very serious is this lack of thorough error handling
+			 * not. Let's just not make mistakes when changing the .ontology
+			 * files for now. */
+
+			g_critical ("%s: Unknown property %s for tracker:domainIndex in %s."
+			            "Don't release this .ontology change!",
 			            ontology_path, object, subject);
 			return;
 		}
@@ -853,12 +868,29 @@ check_for_deleted_domain_index (TrackerClass *class)
 		}
 
 		for (l = deleted; l != NULL; l = l->next) {
+			GError *error = NULL;
 			TrackerProperty *prop = l->data;
-			/* TODO: delete from introspection too */
+
 			g_debug ("Ontology change: deleting tracker:domainIndex: %s",
 			         tracker_property_get_name (prop));
 			tracker_property_del_domain_index (prop, class);
 			tracker_class_del_domain_index (class, prop);
+
+			tracker_data_delete_statement (NULL, tracker_class_get_uri (class),
+			                               TRACKER_PREFIX "domainIndex",
+			                               tracker_property_get_uri (prop),
+			                               &error);
+
+			if (error) {
+				g_critical ("Ontology change, %s", error->message);
+				g_clear_error (&error);
+			} else {
+				tracker_data_update_buffer_flush (&error);
+				if (error) {
+					g_critical ("Ontology change, %s", error->message);
+					g_clear_error (&error);
+				}
+			}
 		}
 
 		g_slist_free (deleted);



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