Merge lp:~mhr3/libunity/no-double-push into lp:~unity-team/libunity/libunity-7.0

Proposed by Michal Hruby
Status: Rejected
Rejected by: Michal Hruby
Proposed branch: lp:~mhr3/libunity/no-double-push
Merge into: lp:~unity-team/libunity/libunity-7.0
Diff against target: 140 lines (+53/-8)
3 files modified
debian/libunity9.symbols (+1/-0)
src/unity-aggregator-scope-private.vala (+43/-8)
src/unity-scope-channel.vala (+9/-0)
To merge this branch: bzr merge lp:~mhr3/libunity/no-double-push
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Unity Team Pending
Review via email: mp+162261@code.launchpad.net

Commit message

Make sure we don't duplicate results when pushing.

Description of the change

Make sure we don't duplicate results when pushing.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~mhr3/libunity/no-double-push updated
378. By Michal Hruby

Invalidate pushed models after each clear

379. By Michal Hruby

Update symbols

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

379. By Michal Hruby

Update symbols

378. By Michal Hruby

Invalidate pushed models after each clear

377. By Michal Hruby

Check scope id when re-pushing results

376. By Michal Hruby

Don't duplicate results on double push

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/libunity9.symbols'
--- debian/libunity9.symbols 2013-05-01 22:30:59 +0000
+++ debian/libunity9.symbols 2013-05-03 22:43:33 +0000
@@ -369,6 +369,7 @@
369 unity_internal_results_synchronizer_prepare_row_buf@Base 6.91.9daily13.04.10ubuntu.unity.experimental.certified369 unity_internal_results_synchronizer_prepare_row_buf@Base 6.91.9daily13.04.10ubuntu.unity.experimental.certified
370 unity_internal_results_synchronizer_remove_provider@Base 6.91.9daily13.04.10ubuntu.unity.experimental.certified370 unity_internal_results_synchronizer_remove_provider@Base 6.91.9daily13.04.10ubuntu.unity.experimental.certified
371 unity_internal_results_synchronizer_set_merge_strategy@Base 6.91.9daily13.04.10ubuntu.unity.experimental.certified371 unity_internal_results_synchronizer_set_merge_strategy@Base 6.91.9daily13.04.10ubuntu.unity.experimental.certified
372 unity_internal_scope_channel_check_pushed_models@Base 0replaceme
372 unity_internal_scope_channel_construct@Base 6.91.9daily13.04.10ubuntu.unity.experimental.certified373 unity_internal_scope_channel_construct@Base 6.91.9daily13.04.10ubuntu.unity.experimental.certified
373 unity_internal_scope_channel_create_channel@Base 6.91.9daily13.04.10ubuntu.unity.experimental.certified374 unity_internal_scope_channel_create_channel@Base 6.91.9daily13.04.10ubuntu.unity.experimental.certified
374 unity_internal_scope_channel_get_filter_by_id@Base 6.91.9daily13.04.10ubuntu.unity.experimental.certified375 unity_internal_scope_channel_get_filter_by_id@Base 6.91.9daily13.04.10ubuntu.unity.experimental.certified
375376
=== modified file 'src/unity-aggregator-scope-private.vala'
--- src/unity-aggregator-scope-private.vala 2013-05-03 18:43:12 +0000
+++ src/unity-aggregator-scope-private.vala 2013-05-03 22:43:33 +0000
@@ -1454,10 +1454,11 @@
14541454
1455 unowned Variant subscopes_filter_variant = hints[SEARCH_SUBSCOPES_HINT];1455 unowned Variant subscopes_filter_variant = hints[SEARCH_SUBSCOPES_HINT];
1456 uint subscope_filter_tag = 0;1456 uint subscope_filter_tag = 0;
1457 string[] enabled_subscopes = {};
1457 if (subscopes_filter_variant != null && subscopes_filter_variant.get_type_string () == "as")1458 if (subscopes_filter_variant != null && subscopes_filter_variant.get_type_string () == "as")
1458 {1459 {
1459 string[] subscopes = (string[]) subscopes_filter_variant;1460 enabled_subscopes = (string[]) subscopes_filter_variant;
1460 subscope_filter_tag = string.joinv (";", subscopes).hash ();1461 subscope_filter_tag = string.joinv (";", enabled_subscopes).hash ();
1461 }1462 }
14621463
1463 bool invalidate_last_search = filter_row_variant != null;1464 bool invalidate_last_search = filter_row_variant != null;
@@ -1498,6 +1499,8 @@
1498 // that are not searched this time disappear1499 // that are not searched this time disappear
1499 synchronizer.clear ();1500 synchronizer.clear ();
15001501
1502 channel.check_pushed_models (search_string);
1503
1501 // if this search will query fewer sources than the last one, there could1504 // if this search will query fewer sources than the last one, there could
1502 // be a race where results from the last query start appearing for this1505 // be a race where results from the last query start appearing for this
1503 // one (cause the sources took a while to complete the search)1506 // one (cause the sources took a while to complete the search)
@@ -1579,7 +1582,12 @@
15791582
1580 foreach (var provider in channel.get_pushed_models (search_string))1583 foreach (var provider in channel.get_pushed_models (search_string))
1581 {1584 {
1582 push_results_internal (synchronizer, provider);1585 unowned string provider_scope_id = provider.get_data<string> ("scope-id");
1586 if (subscope_filter_tag == 0 ||
1587 (subscope_filter_tag != 0 && provider_scope_id in enabled_subscopes))
1588 {
1589 push_results_internal (synchronizer, provider);
1590 }
1583 }1591 }
15841592
1585 int64 search_start_time = 0;1593 int64 search_start_time = 0;
@@ -1893,6 +1901,9 @@
1893 throw new ScopeError.REQUEST_FAILED ("Can't deserialize model");1901 throw new ScopeError.REQUEST_FAILED ("Can't deserialize model");
18941902
1895 var provider = model_obj as Dee.SerializableModel;1903 var provider = model_obj as Dee.SerializableModel;
1904 var synchronizer_tag = new Dee.ModelTag<Dee.ModelIter> (provider);
1905 provider.set_data<Dee.ModelTag<Dee.ModelIter>> ("synchronizer-tag",
1906 synchronizer_tag);
1896 provider.set_data<string> ("uid", "remote:%s".printf (source_scope_id));1907 provider.set_data<string> ("uid", "remote:%s".printf (source_scope_id));
1897 provider.set_data<string> ("scope-id", source_scope_id);1908 provider.set_data<string> ("scope-id", source_scope_id);
1898 var sync = _scopes.get_synchronizer (channel_id);1909 var sync = _scopes.get_synchronizer (channel_id);
@@ -1909,6 +1920,28 @@
1909 throw new ScopeError.REQUEST_FAILED ("Merging not implemented");1920 throw new ScopeError.REQUEST_FAILED ("Merging not implemented");
1910 }1921 }
19111922
1923 // are we trying to re-push results for the same scope? if so, remove
1924 // the previous pushed results first
1925 foreach (var pushed_model in channel.get_pushed_models (search_string))
1926 {
1927 if (pushed_model.get_data<string> ("scope-id") == source_scope_id)
1928 {
1929 var tag = pushed_model.get_data<Dee.ModelTag<Dee.ModelIter>> ("synchronizer-tag");
1930 var iter = pushed_model.get_first_iter ();
1931 var end_iter = pushed_model.get_last_iter ();
1932 while (iter != end_iter)
1933 {
1934 var target_iter = tag[pushed_model, iter];
1935 if (target_iter != null)
1936 {
1937 sync.receiver.remove (target_iter);
1938 tag.clear (pushed_model, iter);
1939 }
1940 iter = pushed_model.next (iter);
1941 }
1942 }
1943 }
1944
1912 channel.register_pushed_model (search_string, provider);1945 channel.register_pushed_model (search_string, provider);
19131946
1914 push_results_internal (sync, provider);1947 push_results_internal (sync, provider);
@@ -1929,21 +1962,23 @@
1929 private void push_results_internal (ResultsSynchronizer synchronizer,1962 private void push_results_internal (ResultsSynchronizer synchronizer,
1930 Dee.SerializableModel provider)1963 Dee.SerializableModel provider)
1931 {1964 {
1965 var tag = provider.get_data<Dee.ModelTag<Dee.ModelIter>> ("synchronizer-tag");
1932 var iter = provider.get_first_iter ();1966 var iter = provider.get_first_iter ();
1933 var end = provider.get_last_iter ();1967 var end = provider.get_last_iter ();
1934 /* everything is prepared now, we can push results directly1968 /* everything is prepared now, we can push results directly
1935 * into the synchronizer */1969 * into the synchronizer */
1970 unowned string source_scope_id = provider.get_data<string> ("scope-id");
1936 while (iter != end)1971 while (iter != end)
1937 {1972 {
1938 unowned string source_scope_id = provider.get_data<string> ("scope-id");
1939 unowned Variant[] row_buf = synchronizer.prepare_row_buf (provider, iter);1973 unowned Variant[] row_buf = synchronizer.prepare_row_buf (provider, iter);
1940 synchronizer.merge_strategy.merge_result (source_scope_id,1974 var target_iter = synchronizer.merge_strategy.merge_result (
1941 synchronizer.receiver, row_buf);1975 source_scope_id, synchronizer.receiver, row_buf);
1942 // inform the synchronizer (or rather its listeners) about the changes1976 tag[provider, iter] = target_iter;
1943 synchronizer.transaction_complete (provider, source_scope_id);
19441977
1945 iter = provider.next (iter);1978 iter = provider.next (iter);
1946 }1979 }
1980 // inform the synchronizer (or rather its listeners) about the changes
1981 synchronizer.transaction_complete (provider, source_scope_id);
1947 }1982 }
19481983
1949 /* DBus properties */1984 /* DBus properties */
19501985
=== modified file 'src/unity-scope-channel.vala'
--- src/unity-scope-channel.vala 2013-05-01 20:56:04 +0000
+++ src/unity-scope-channel.vala 2013-05-03 22:43:33 +0000
@@ -223,6 +223,15 @@
223 pushed_models.append (model);223 pushed_models.append (model);
224 }224 }
225225
226 public void check_pushed_models (string search_string)
227 {
228 if (last_push_search_string != search_string)
229 {
230 // invalidate pushed models
231 pushed_models = new GLib.List<Dee.SerializableModel> ();
232 }
233 }
234
226 public GLib.List<unowned Dee.SerializableModel> get_pushed_models (string search_string)235 public GLib.List<unowned Dee.SerializableModel> get_pushed_models (string search_string)
227 {236 {
228 if (last_push_search_string != search_string)237 if (last_push_search_string != search_string)

Subscribers

People subscribed via source and target branches

to all changes: