← Back to team overview

zeitgeist team mailing list archive

[Branch ~zeitgeist/zeitgeist/bluebird] Rev 364: Fix bug 909708 where inserting and event with 2 subjects.

 

Merge authors:
  Seif Lotfy (seif)
Related merge proposals:
  https://code.launchpad.net/~zeitgeist/zeitgeist/fix-909708/+merge/87228
  proposed by: Seif Lotfy (seif)
  review: Approve - Siegfried Gevatter (rainct)
------------------------------------------------------------
revno: 364 [merge]
committer: Seif Lotfy <seif@xxxxxxxxx>
branch nick: zeitgeist
timestamp: Tue 2012-01-03 20:43:38 +0100
message:
  Fix bug 909708 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
modified:
  src/engine.vala
  test/dbus/remote-test.py


--
lp:zeitgeist
https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird

Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist.
To unsubscribe from this branch go to https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird/+edit-subscription
=== modified file 'src/engine.vala'
--- src/engine.vala	2011-12-31 18:17:04 +0000
+++ src/engine.vala	2012-01-02 18:37:24 +0000
@@ -584,13 +584,23 @@
             var uris = new GenericArray<string> ();
             var texts = new GenericArray<string> ();
             var storages = new GenericArray<string> ();
+            var subj_uris = new SList<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)
+                {
+                    // Events with two subjects with the same URI are not supported.
+                    warning ("Events with two subjects with the same URI are not supported");
+                    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:42:53 +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):
 	"""