[tracker/sam/tracker-3.0-functional-tests: 95/100] libtracker-sparql: Correctly notify DELETE events



commit a06eb6799fae993650c27ef655f02febe1a6e04c
Author: Sam Thursfield <sam afuera me uk>
Date:   Sat Feb 8 16:01:56 2020 +0100

    libtracker-sparql: Correctly notify DELETE events

 src/libtracker-direct/tracker-direct.c | 12 +++++-------
 tests/functional-tests/14-signals.py   |  4 +++-
 2 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/src/libtracker-direct/tracker-direct.c b/src/libtracker-direct/tracker-direct.c
index 8527f9672..68cb435f9 100644
--- a/src/libtracker-direct/tracker-direct.c
+++ b/src/libtracker-direct/tracker-direct.c
@@ -452,16 +452,13 @@ delete_statement_cb (gint         graph_id,
        TrackerOntologies *ontologies = tracker_data_manager_get_ontologies (priv->data_manager);
        TrackerProperty *rdf_type = tracker_ontologies_get_rdf_type (ontologies);
        TrackerNotifierEventCache *cache;
-       TrackerClass *new_class = NULL;
+       TrackerClass *class_being_removed = NULL;
        gint i;
 
        cache = lookup_event_cache (notifier, graph_id, graph);
 
        if (predicate_id == tracker_property_get_id (rdf_type)) {
-               const gchar *uri;
-
-               uri = tracker_ontologies_get_uri_by_id (ontologies, predicate_id);
-               new_class = tracker_ontologies_get_class_by_uri (ontologies, uri);
+               class_being_removed = tracker_ontologies_get_class_by_uri (ontologies, object);
        }
 
        for (i = 0; i < rdf_types->len; i++) {
@@ -471,10 +468,11 @@ delete_statement_cb (gint         graph_id,
                if (!tracker_class_get_notify (class))
                        continue;
 
-               if (class == new_class)
+               if (class_being_removed && class == class_being_removed) {
                        event_type = TRACKER_NOTIFIER_EVENT_DELETE;
-               else
+               } else {
                        event_type = TRACKER_NOTIFIER_EVENT_UPDATE;
+               }
 
                _tracker_notifier_event_cache_push_event (cache, subject_id, event_type);
        }
diff --git a/tests/functional-tests/14-signals.py b/tests/functional-tests/14-signals.py
index 8cf349edd..944e57a7c 100644
--- a/tests/functional-tests/14-signals.py
+++ b/tests/functional-tests/14-signals.py
@@ -149,6 +149,7 @@ class TrackerStoreSignalsTests (CommonTrackerStoreTest):
 
         # Validate results:
         self.assertEqual(len(self.results_deletes), 1)
+        self.assertEqual(len(self.results_updates), 1)
         self.assertEqual(len(self.results_inserts), 0)
 
     def test_03_update_contact(self):
@@ -164,8 +165,9 @@ class TrackerStoreSignalsTests (CommonTrackerStoreTest):
             "INSERT { <test://signals-contact-update> nco:fullname 'wohoo'}")
         self.__wait_for_signal()
 
+        self.assertEqual(len(self.results_updates), 2)
+        self.assertEqual(len(self.results_inserts), 0)
         self.assertEqual(len(self.results_deletes), 0)
-        self.assertEqual(len(self.results_inserts), 1)
 
     def test_04_fullupdate_contact(self):
         self.clean_up_list.append("test://signals-contact-fullupdate")


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