diff options
author | Victor Shyba <victor1984@riseup.net> | 2016-10-19 02:14:46 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2016-12-12 09:12:00 -0200 |
commit | 288434178a4e89f86b9740cfe77a4dc0ce9e45f7 (patch) | |
tree | 783e5d62a48fad4f31782922386bd0ef76c14505 /client/src | |
parent | 8ff1f0b781c49b88da13af390e4d118ad3e77b43 (diff) |
[bug] total number of documents
Parsing from metadata we can store the total of docs and handle it for
the doc parser in order to be able to keep consistent events info.
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/leap/soledad/client/http_target/fetch.py | 4 | ||||
-rw-r--r-- | client/src/leap/soledad/client/http_target/fetch_protocol.py | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/client/src/leap/soledad/client/http_target/fetch.py b/client/src/leap/soledad/client/http_target/fetch.py index 036b5b21..bbc743e1 100644 --- a/client/src/leap/soledad/client/http_target/fetch.py +++ b/client/src/leap/soledad/client/http_target/fetch.py @@ -97,7 +97,7 @@ class HTTPDocFetcher(object): body_reader=body_reader) @defer.inlineCallbacks - def _doc_parser(self, doc_info, content): + def _doc_parser(self, doc_info, content, total): """ Insert a received document into the local replica. @@ -127,7 +127,7 @@ class HTTPDocFetcher(object): doc, doc_info['gen'], doc_info['trans_id']) self._received_docs += 1 user_data = {'uuid': self.uuid, 'userid': self.userid} - _emit_receive_status(user_data, self._received_docs, total=1000000) + _emit_receive_status(user_data, self._received_docs, total=total) def _parse_metadata(self, metadata): """ diff --git a/client/src/leap/soledad/client/http_target/fetch_protocol.py b/client/src/leap/soledad/client/http_target/fetch_protocol.py index 29801819..4290785d 100644 --- a/client/src/leap/soledad/client/http_target/fetch_protocol.py +++ b/client/src/leap/soledad/client/http_target/fetch_protocol.py @@ -113,11 +113,13 @@ class DocStreamReceiver(ReadBodyProtocol): elif self._line == 1: self.metadata = line assert 'error' not in self.metadata + self.total = json.loads(line).get('number_of_changes', -1) elif (self._line % 2) == 0: self.current_doc = json.loads(line) assert 'error' not in self.current_doc else: - self._doc_reader(self.current_doc, line.strip() or None) + self._doc_reader( + self.current_doc, line.strip() or None, self.total) def finish(self): """ |