Merge lp:~zeitgeist/zeitgeist/fix-909708 into lp:~zeitgeist/zeitgeist/bluebird

Proposed by Seif Lotfy
Status: Merged
Merge reported by: Seif Lotfy
Merged at revision: not available
Proposed branch: lp:~zeitgeist/zeitgeist/fix-909708
Merge into: lp:~zeitgeist/zeitgeist/bluebird
Diff against target: 39 lines (+11/-0)
2 files modified
src/engine.vala (+10/-0)
test/dbus/remote-test.py (+1/-0)
To merge this branch: bzr merge lp:~zeitgeist/zeitgeist/fix-909708
Reviewer Review Type Date Requested Status
Siegfried Gevatter Approve
Review via email: mp+87228@code.launchpad.net

Description of the change

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

To post a comment you must log in.
Revision history for this message
Siegfried Gevatter (rainct) wrote :

 - Why do you use a List? Make that a SList. Even better, we know how many subjects there are so we can just use a fixed size array or something.

 - Fix the formatting: "null) {", ".append(s".

 - A comment before the "return 0" explaining what happened would be nice ("// Events with two subjects with the same URI are not supported."). Also, return a warning so people will notice they're doing it wrong.

review: Needs Fixing
lp:~zeitgeist/zeitgeist/fix-909708 updated
363. By Seif Lotfy

fixed style and replaced list with slist as well as print out a warning upon detection of 2 identical uris in same event2

Revision history for this message
Siegfried Gevatter (rainct) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/engine.vala'
--- src/engine.vala 2011-12-31 18:17:04 +0000
+++ src/engine.vala 2012-01-02 18:41:26 +0000
@@ -584,13 +584,23 @@
584 var uris = new GenericArray<string> ();584 var uris = new GenericArray<string> ();
585 var texts = new GenericArray<string> ();585 var texts = new GenericArray<string> ();
586 var storages = new GenericArray<string> ();586 var storages = new GenericArray<string> ();
587 var subj_uris = new SList<string> ();
587588
588 if (event.origin != "")589 if (event.origin != "")
589 uris.add (event.origin);590 uris.add (event.origin);
590591
592 // Iterate through subjects and check for validity
591 for (int i = 0; i < event.num_subjects(); ++i)593 for (int i = 0; i < event.num_subjects(); ++i)
592 {594 {
593 unowned Subject subject = event.subjects[i];595 unowned Subject subject = event.subjects[i];
596 if (subj_uris.find_custom(subject.uri, strcmp) != null)
597 {
598 // Events with two subjects with the same URI are not supported.
599 warning ("Events with two subjects with the same URI are not supported");
600 return 0;
601 }
602 subj_uris.append (subject.uri);
603
594 uris.add (subject.uri);604 uris.add (subject.uri);
595605
596 if (subject.current_uri == "" || subject.current_uri == null)606 if (subject.current_uri == "" || subject.current_uri == null)
597607
=== 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 18:41:26 +0000
@@ -252,6 +252,7 @@
252 events[0].subjects.append(list(events[0].subjects[0]))252 events[0].subjects.append(list(events[0].subjects[0]))
253 ids = self.insertEventsAndWait(events)253 ids = self.insertEventsAndWait(events)
254 self.assertEquals(3, len(set(ids)))254 self.assertEquals(3, len(set(ids)))
255 self.assertEquals(0, ids[0])
255256
256class ZeitgeistRemoteFindEventIdsTest(testutils.RemoteTestCase):257class ZeitgeistRemoteFindEventIdsTest(testutils.RemoteTestCase):
257 """258 """

Subscribers

People subscribed via source and target branches