From 6da5ce6286336f5945e2eff5ceb0ae10116f8546 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Mon, 27 Mar 2017 23:13:58 -0300 Subject: [feature] add send_missing to send pending uploads This method will gather a list of local docs and a list of remote docs, compare them and send docs which server doesn't have. - Related: #8807 --- client/src/leap/soledad/client/_blobs.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'client/src') diff --git a/client/src/leap/soledad/client/_blobs.py b/client/src/leap/soledad/client/_blobs.py index b7dee538..fac65383 100644 --- a/client/src/leap/soledad/client/_blobs.py +++ b/client/src/leap/soledad/client/_blobs.py @@ -167,6 +167,18 @@ class BlobManager(object): def local_list(self): return self.local.list() + @defer.inlineCallbacks + def send_missing(self): + our_blobs = yield self.local_list() + server_blobs = yield self.remote_list() + missing = [b_id for b_id in our_blobs if b_id not in server_blobs] + logger.info("Amount of documents missing on server: %s" % len(missing)) + # TODO: Send concurrently when we are able to stream directly from db + for blob_id in missing: + fd = yield self.local.get(blob_id) + logger.info("Upload local blob: %s" % blob_id) + yield self._encrypt_and_upload(blob_id, fd) + @defer.inlineCallbacks def put(self, doc, size): fd = doc.blob_fd -- cgit v1.2.3