[tracker/wip/carlosg/update-perf: 12/65] libtracker-data: Shuffle handling of properties not belonging to a class




commit decf091009540a763bf2716ef685a61103ebcdc7
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Jan 18 14:13:22 2022 +0100

    libtracker-data: Shuffle handling of properties not belonging to a class
    
    We currently warn if we are setting a property on a resource that is not
    expected due to missing rdf:type. This is only relevant while handling
    insertion of new data, all other places use get_old_property_values() in
    places where either data is being deleted, or we know we deal with
    properties in the domain of the resource.
    
    Move this error to the place where it should be handled, instead of doing
    it generically from get_old_property_values().

 src/libtracker-sparql/core/tracker-data-update.c | 59 +++++++++++-------------
 1 file changed, 28 insertions(+), 31 deletions(-)
---
diff --git a/src/libtracker-sparql/core/tracker-data-update.c 
b/src/libtracker-sparql/core/tracker-data-update.c
index b5f6c660f..b30366823 100644
--- a/src/libtracker-sparql/core/tracker-data-update.c
+++ b/src/libtracker-sparql/core/tracker-data-update.c
@@ -1639,38 +1639,8 @@ get_old_property_values (TrackerData      *data,
 
        /* read existing property values */
        old_values = g_hash_table_lookup (data->resource_buffer->predicates, property);
-       if (old_values == NULL) {
-               if (!check_property_domain (data, property)) {
-                       if (data->implicit_create) {
-                               if (!cache_create_service_decomposed (data,
-                                                                     tracker_property_get_domain (property),
-                                                                     error))
-                                       return NULL;
-                       } else {
-                               TrackerDBInterface *iface;
-                               gchar *resource;
-
-                               iface = tracker_data_manager_get_writable_db_interface (data->manager);
-                               resource = tracker_data_query_resource_urn (data->manager,
-                                                                           iface,
-                                                                           data->resource_buffer->id);
-
-                               g_set_error (error, TRACKER_SPARQL_ERROR, TRACKER_SPARQL_ERROR_CONSTRAINT,
-                                            "%s %s is not is not a %s, cannot have property `%s'",
-                                            resource ? "Subject" : "Blank node",
-                                            resource ? resource : "",
-                                            tracker_class_get_name (tracker_property_get_domain (property)),
-                                            tracker_property_get_name (property));
-                               g_free (resource);
-
-                               return NULL;
-                       }
-               }
-
-               data->resource_buffer->fts_updated |=
-                       tracker_property_get_fulltext_indexed (property);
+       if (old_values == NULL)
                old_values = get_property_values (data, property, error);
-       }
 
        return old_values;
 }
@@ -1788,6 +1758,33 @@ cache_insert_metadata_decomposed (TrackerData      *data,
        GError             *new_error = NULL;
        gboolean            change = FALSE;
 
+       if (!check_property_domain (data, property)) {
+               if (data->implicit_create) {
+                       if (!cache_create_service_decomposed (data,
+                                                             tracker_property_get_domain (property),
+                                                             error))
+                               return FALSE;
+               } else {
+                       TrackerDBInterface *iface;
+                       gchar *resource;
+
+                       iface = tracker_data_manager_get_writable_db_interface (data->manager);
+                       resource = tracker_data_query_resource_urn (data->manager,
+                                                                   iface,
+                                                                   data->resource_buffer->id);
+
+                       g_set_error (error, TRACKER_SPARQL_ERROR, TRACKER_SPARQL_ERROR_CONSTRAINT,
+                                    "%s %s is not is not a %s, cannot have property `%s'",
+                                    resource ? "Subject" : "Blank node",
+                                    resource ? resource : "",
+                                    tracker_class_get_name (tracker_property_get_domain (property)),
+                                    tracker_property_get_name (property));
+                       g_free (resource);
+
+                       return FALSE;
+               }
+       }
+
        /* read existing property values */
        old_values = get_old_property_values (data, property, &new_error);
        if (new_error) {


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