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
1=== modified file 'src/engine.vala'
2--- src/engine.vala 2011-12-31 18:17:04 +0000
3+++ src/engine.vala 2012-01-02 18:41:26 +0000
4@@ -584,13 +584,23 @@
5 var uris = new GenericArray<string> ();
6 var texts = new GenericArray<string> ();
7 var storages = new GenericArray<string> ();
8+ var subj_uris = new SList<string> ();
9
10 if (event.origin != "")
11 uris.add (event.origin);
12
13+ // Iterate through subjects and check for validity
14 for (int i = 0; i < event.num_subjects(); ++i)
15 {
16 unowned Subject subject = event.subjects[i];
17+ if (subj_uris.find_custom(subject.uri, strcmp) != null)
18+ {
19+ // Events with two subjects with the same URI are not supported.
20+ warning ("Events with two subjects with the same URI are not supported");
21+ return 0;
22+ }
23+ subj_uris.append (subject.uri);
24+
25 uris.add (subject.uri);
26
27 if (subject.current_uri == "" || subject.current_uri == null)
28
29=== modified file 'test/dbus/remote-test.py'
30--- test/dbus/remote-test.py 2011-12-29 13:59:16 +0000
31+++ test/dbus/remote-test.py 2012-01-02 18:41:26 +0000
32@@ -252,6 +252,7 @@
33 events[0].subjects.append(list(events[0].subjects[0]))
34 ids = self.insertEventsAndWait(events)
35 self.assertEquals(3, len(set(ids)))
36+ self.assertEquals(0, ids[0])
37
38 class ZeitgeistRemoteFindEventIdsTest(testutils.RemoteTestCase):
39 """

Subscribers

People subscribed via source and target branches