diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/leap/soledad/client/_db/blobs/sql.py | 7 | ||||
-rw-r--r-- | src/leap/soledad/client/_db/blobs/sync.py | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/leap/soledad/client/_db/blobs/sql.py b/src/leap/soledad/client/_db/blobs/sql.py index c5b0b64b..5337ab87 100644 --- a/src/leap/soledad/client/_db/blobs/sql.py +++ b/src/leap/soledad/client/_db/blobs/sql.py @@ -190,6 +190,13 @@ class SQLiteBlobBackend(object): query = 'DELETE FROM blobs WHERE blob_id = ? AND namespace = ?' return self.dbpool.runQuery(query, (blob_id, namespace,)) + def batch_delete(self, blob_id_list, namespace=''): + query = 'DELETE FROM blobs WHERE blob_id IN ' + size = len(blob_id_list) + query += ('(%s)' % ', '.join(['?' for _ in range(size)])) + values = tuple(blob_id_list) + return self.dbpool.runQuery(query, values) + def _init_tables(conn): # unified init for running under the same lock diff --git a/src/leap/soledad/client/_db/blobs/sync.py b/src/leap/soledad/client/_db/blobs/sync.py index bfdc5fbe..bdfbb983 100644 --- a/src/leap/soledad/client/_db/blobs/sync.py +++ b/src/leap/soledad/client/_db/blobs/sync.py @@ -73,6 +73,12 @@ class BlobsSynchronizer(object): namespace=namespace) @defer.inlineCallbacks + def _apply_deletions_from_server(self, namespace=''): + remote_deletions = self.remote_list(namespace=namespace, deleted=True) + remote_deletions = yield remote_deletions + yield self.local.batch_delete(remote_deletions) + + @defer.inlineCallbacks def send_missing(self, namespace=''): """ Compare local and remote blobs and send what's missing in server. @@ -131,6 +137,7 @@ class BlobsSynchronizer(object): @defer.inlineCallbacks def sync(self, namespace=''): try: + yield self._apply_deletions_from_server(namespace) yield self.refresh_sync_status_from_server(namespace) yield self.fetch_missing(namespace) yield self.send_missing(namespace) |