summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/src/leap/soledad/client/api.py17
-rw-r--r--client/src/leap/soledad/client/sync.py8
2 files changed, 10 insertions, 15 deletions
diff --git a/client/src/leap/soledad/client/api.py b/client/src/leap/soledad/client/api.py
index df69037c..01c06f20 100644
--- a/client/src/leap/soledad/client/api.py
+++ b/client/src/leap/soledad/client/api.py
@@ -38,6 +38,7 @@ try:
import cchardet as chardet
except ImportError:
import chardet
+from itertools import chain
from StringIO import StringIO
from u1db.remote import http_client
@@ -679,19 +680,19 @@ class Soledad(object):
defer_decryption=defer_decryption)
def _sync_callback(local_gen):
- self._last_received_docs = self._dbsyncer.received_docs
- print "***"
- print "LAST RECEIVED (API)", self._last_received_docs
- print "***"
- received_doc_ids = self._dbsyncer.received_docs
+ self._last_received_docs = docs = self._dbsyncer.received_docs
# Post-Sync Hooks
synced_plugin = soledad_interfaces.ISoledadPostSyncPlugin
- if received_doc_ids:
+ if docs:
suitable_plugins = collect_plugins(synced_plugin)
for plugin in suitable_plugins:
- # TODO filter the doc_ids here
- plugin.process_received_docs(received_doc_ids)
+ watched = plugin.watched_doc_types
+ r = [filter(
+ lambda s: s.startswith(preffix),
+ docs) for preffix in watched]
+ filtered = list(chain(*r))
+ plugin.process_received_docs(filtered)
soledad_events.emit(
soledad_events.SOLEDAD_DONE_DATA_SYNC, self.uuid)
diff --git a/client/src/leap/soledad/client/sync.py b/client/src/leap/soledad/client/sync.py
index 917c21ea..14c547cf 100644
--- a/client/src/leap/soledad/client/sync.py
+++ b/client/src/leap/soledad/client/sync.py
@@ -158,15 +158,9 @@ class SoledadSynchronizer(Synchronizer):
_, _, changes = self.source.whats_changed(target_my_gen)
changed_doc_ids = [doc_id for doc_id, _, _ in changes]
- print "--------------------------"
- print "SENT", ids_sent
- print "CHANGED_DOC_IDS", changed_doc_ids
-
just_received = list(set(changed_doc_ids) - set(ids_sent))
- print "RECEIVED:", just_received
- print "--------------------------"
-
self.received_docs = just_received
+
defer.returnValue(my_gen)
def complete_sync(self):