← Back to team overview

zeitgeist team mailing list archive

[Merge] lp:~zeitgeist/zeitgeist/fix-909708 into lp:zeitgeist

 

Seif Lotfy has proposed merging lp:~zeitgeist/zeitgeist/fix-909708 into lp:zeitgeist.

Requested reviews:
  Zeitgeist Framework Team (zeitgeist)
Related bugs:
  Bug #909708 in Zeitgeist Framework: "Inserting event with two subjects with the same URI breaks the following event"
  https://bugs.launchpad.net/zeitgeist/+bug/909708

For more details, see:
https://code.launchpad.net/~zeitgeist/zeitgeist/fix-909708/+merge/87228

This branch fixes the issue where inserting and event with 2 subjects.
Since we already parse the subjects before insertion I added a list with subj_uris to find if there is a duplicate and return 0 if one is found
-- 
https://code.launchpad.net/~zeitgeist/zeitgeist/fix-909708/+merge/87228
Your team Zeitgeist Framework Team is requested to review the proposed merge of lp:~zeitgeist/zeitgeist/fix-909708 into lp:zeitgeist.
=== modified file 'src/engine.vala'
--- src/engine.vala	2011-12-31 18:17:04 +0000
+++ src/engine.vala	2012-01-02 07:44:24 +0000
@@ -584,13 +584,20 @@
             var uris = new GenericArray<string> ();
             var texts = new GenericArray<string> ();
             var storages = new GenericArray<string> ();
+            var subj_uris = new List<string> ();
 
             if (event.origin != "")
                 uris.add (event.origin);
 
+            // Iterate through subjects and check for validity
             for (int i = 0; i < event.num_subjects(); ++i)
             {
                 unowned Subject subject = event.subjects[i];
+                if (subj_uris.find_custom(subject.uri, strcmp) != null) {
+                    return 0;
+                }
+                subj_uris.append(subject.uri);
+
                 uris.add (subject.uri);
 
                 if (subject.current_uri == "" || subject.current_uri == null)

=== modified file 'test/dbus/remote-test.py'
--- test/dbus/remote-test.py	2011-12-29 13:59:16 +0000
+++ test/dbus/remote-test.py	2012-01-02 07:44:24 +0000
@@ -252,6 +252,7 @@
 		events[0].subjects.append(list(events[0].subjects[0]))
 		ids = self.insertEventsAndWait(events)
 		self.assertEquals(3, len(set(ids)))
+		self.assertEquals(0, ids[0])
 
 class ZeitgeistRemoteFindEventIdsTest(testutils.RemoteTestCase):
 	"""


Follow ups