summaryrefslogtreecommitdiff
path: root/client/src
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2015-06-05 11:41:32 -0400
committerKali Kaneko <kali@leap.se>2015-06-15 14:24:20 -0400
commitb5116f79a121c6a9360faa29e7da095a09d14494 (patch)
tree6b406180986016f3b3ef82e82ae294d2d3f1ac52 /client/src
parent387658fe99549e071edb05bb35a35831d46f38f6 (diff)
[feature] filter documents before passing them to the plugin
Diffstat (limited to 'client/src')
-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):