[tracker/property-changes-for-review] libtracker-data: Do a check for valid range conversion before making any changes
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/property-changes-for-review] libtracker-data: Do a check for valid range conversion before making any changes
- Date: Tue, 6 Apr 2010 14:00:27 +0000 (UTC)
commit f5a5a73ca5f757811914daff9b652dea565e9837
Author: Philip Van Hoof <philip codeminded be>
Date: Tue Apr 6 15:59:24 2010 +0200
libtracker-data: Do a check for valid range conversion before making any changes
src/libtracker-data/tracker-data-manager.c | 38 ++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index e770827..5b38424 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -245,6 +245,40 @@ update_property_value (const gchar *kind,
static void
+check_range_conversion_is_allowed (const gchar *subject,
+ const gchar *predicate,
+ const gchar *object)
+{
+ TrackerDBResultSet *result_set;
+ gchar *query;
+
+ query = g_strdup_printf ("SELECT ?old_value WHERE { "
+ "<%s> rdfs:range ?old_value "
+ "}", subject);
+
+ result_set = tracker_data_query_sparql (query, NULL);
+
+ g_free (query);
+
+ if (result_set) {
+ gchar *str = NULL;
+ tracker_db_result_set_get (result_set, 0, &str, -1);
+
+ if (g_strcmp0 (object, str) != 0) {
+ if (!is_allowed_conversion (str, object, allowed_range_conversions)) {
+ g_error ("Ontology change conversion not allowed '%s' -> '%s' in '%s' of '%s'",
+ str, object, predicate, subject);
+ }
+ }
+ g_free (str);
+ }
+
+ if (result_set) {
+ g_object_unref (result_set);
+ }
+}
+
+static void
fix_indexed (TrackerProperty *property, gboolean enabled)
{
TrackerDBInterface *iface;
@@ -487,6 +521,10 @@ tracker_data_ontology_load_statement (const gchar *ontology_path,
return;
}
+ if (tracker_property_get_is_new (property) != in_update) {
+ check_range_conversion_is_allowed (subject, predicate, object);
+ }
+
range = tracker_ontologies_get_class_by_uri (object);
if (range == NULL) {
g_critical ("%s: Unknown class %s", ontology_path, object);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]