diff options
-rw-r--r-- | src/libtracker-data/tracker-class.c | 32 | ||||
-rw-r--r-- | src/libtracker-data/tracker-class.h | 2 | ||||
-rw-r--r-- | src/libtracker-data/tracker-data-manager.c | 52 |
3 files changed, 85 insertions, 1 deletions
diff --git a/src/libtracker-data/tracker-class.c b/src/libtracker-data/tracker-class.c index 7486032ad..882ec3935 100644 --- a/src/libtracker-data/tracker-class.c +++ b/src/libtracker-data/tracker-class.c @@ -44,6 +44,7 @@ struct _TrackerClassPrivate { GArray *super_classes; GArray *domain_indexes; GArray *last_domain_indexes; + GArray *last_super_classes; struct { struct { @@ -92,6 +93,7 @@ tracker_class_init (TrackerClass *service) priv->super_classes = g_array_new (TRUE, TRUE, sizeof (TrackerClass *)); priv->domain_indexes = g_array_new (TRUE, TRUE, sizeof (TrackerProperty *)); priv->last_domain_indexes = NULL; + priv->last_super_classes = NULL; priv->deletes.pending.sub_pred_ids = g_array_new (FALSE, FALSE, sizeof (gint64)); priv->deletes.pending.obj_graph_ids = g_array_new (FALSE, FALSE, sizeof (gint64)); @@ -130,9 +132,13 @@ class_finalize (GObject *object) g_array_free (priv->inserts.ready.sub_pred_ids, TRUE); g_array_free (priv->inserts.ready.obj_graph_ids, TRUE); - if (priv->last_domain_indexes) + if (priv->last_domain_indexes) { g_array_free (priv->last_domain_indexes, TRUE); + } + if (priv->last_super_classes) { + g_array_free (priv->last_super_classes, TRUE); + } (G_OBJECT_CLASS (tracker_class_parent_class)->finalize) (object); } @@ -232,6 +238,18 @@ tracker_class_get_last_domain_indexes (TrackerClass *service) return (TrackerProperty **) (priv->last_domain_indexes ? priv->last_domain_indexes->data : NULL); } +TrackerClass ** +tracker_class_get_last_super_classes (TrackerClass *service) +{ + TrackerClassPrivate *priv; + + g_return_val_if_fail (TRACKER_IS_CLASS (service), NULL); + + priv = GET_PRIV (service); + + return (TrackerClass **) (priv->last_super_classes ? priv->last_super_classes->data : NULL); +} + gboolean tracker_class_get_is_new (TrackerClass *service) { @@ -351,6 +369,18 @@ tracker_class_add_super_class (TrackerClass *service, } void +tracker_class_reset_super_classes (TrackerClass *service) +{ + TrackerClassPrivate *priv; + + g_return_if_fail (TRACKER_IS_CLASS (service)); + + priv = GET_PRIV (service); + priv->last_super_classes = priv->super_classes; + priv->super_classes = g_array_new (TRUE, TRUE, sizeof (TrackerClass *)); +} + +void tracker_class_add_domain_index (TrackerClass *service, TrackerProperty *value) { diff --git a/src/libtracker-data/tracker-class.h b/src/libtracker-data/tracker-class.h index 2b4d5c1fb..118dddf2e 100644 --- a/src/libtracker-data/tracker-class.h +++ b/src/libtracker-data/tracker-class.h @@ -69,6 +69,7 @@ gboolean tracker_class_get_notify (TrackerClass *ser TrackerClass **tracker_class_get_super_classes (TrackerClass *service); TrackerProperty **tracker_class_get_domain_indexes (TrackerClass *service); TrackerProperty **tracker_class_get_last_domain_indexes(TrackerClass *service); +TrackerClass **tracker_class_get_last_super_classes (TrackerClass *service); void tracker_class_set_uri (TrackerClass *service, const gchar *value); @@ -81,6 +82,7 @@ void tracker_class_add_domain_index (TrackerClass *ser void tracker_class_del_domain_index (TrackerClass *service, TrackerProperty *value); void tracker_class_reset_domain_indexes (TrackerClass *service); +void tracker_class_reset_super_classes (TrackerClass *service); void tracker_class_set_id (TrackerClass *service, gint id); void tracker_class_set_is_new (TrackerClass *service, diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c index a6a34ec1b..b8ec57cf7 100644 --- a/src/libtracker-data/tracker-data-manager.c +++ b/src/libtracker-data/tracker-data-manager.c @@ -541,6 +541,7 @@ tracker_data_ontology_load_statement (const gchar *ontology_path, } else { /* Reset for a correct post-check */ tracker_class_reset_domain_indexes (class); + tracker_class_reset_super_classes (class); tracker_class_set_notify (class, FALSE); } return; @@ -1255,6 +1256,49 @@ check_for_deleted_domain_index (TrackerClass *class) } static void +check_for_deleted_super_classes (TrackerClass *class, + GError **error) +{ + TrackerClass **last_super_classes; + + last_super_classes = tracker_class_get_last_super_classes (class); + + if (!last_super_classes) { + return; + } + + while (*last_super_classes) { + TrackerClass *last_super_class = *last_super_classes; + gboolean found = FALSE; + TrackerClass **super_classes; + + super_classes = tracker_class_get_super_classes (class); + + while (*super_classes) { + TrackerClass *super_class = *super_classes; + if (last_super_class == super_class) { + found = TRUE; + break; + } + super_classes++; + } + + if (!found) { + const gchar *ontology_path = "Unknown"; + const gchar *subject = tracker_class_get_uri (class); + + handle_unsupported_ontology_change (ontology_path, + subject, + "rdfs:subClassOf", "-", "-", + error); + return; + } + + last_super_classes++; + } +} + +static void tracker_data_ontology_process_changes_pre_db (GPtrArray *seen_classes, GPtrArray *seen_properties, GError **error) @@ -1262,8 +1306,16 @@ tracker_data_ontology_process_changes_pre_db (GPtrArray *seen_classes, gint i; if (seen_classes) { for (i = 0; i < seen_classes->len; i++) { + GError *n_error = NULL; TrackerClass *class = g_ptr_array_index (seen_classes, i); + check_for_deleted_domain_index (class); + check_for_deleted_super_classes (class, &n_error); + + if (n_error) { + g_propagate_error (error, n_error); + return; + } } } |