From afdb1cefe605cabfe325df3124b9beb3174568ff Mon Sep 17 00:00:00 2001 From: drebs Date: Mon, 4 Aug 2014 16:48:21 -0300 Subject: Delete the received docs from sync db before starting a new sync. --- client/src/leap/soledad/client/crypto.py | 7 +++++++ client/src/leap/soledad/client/target.py | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'client/src/leap') diff --git a/client/src/leap/soledad/client/crypto.py b/client/src/leap/soledad/client/crypto.py index 1b01913d..a24f2053 100644 --- a/client/src/leap/soledad/client/crypto.py +++ b/client/src/leap/soledad/client/crypto.py @@ -986,3 +986,10 @@ class SyncDecrypterPool(SyncEncryptDecryptPool): else: # If no errors found, remove it from the received database. self.delete_received_doc(doc_id, doc_rev) + + def empty(self): + """ + Empty the received docs table of the sync database. + """ + sql = "DELETE FROM %s WHERE 1" % (self.TABLE_NAME,) + res = self._sync_db.execute(sql) diff --git a/client/src/leap/soledad/client/target.py b/client/src/leap/soledad/client/target.py index 12175f48..1cb02856 100644 --- a/client/src/leap/soledad/client/target.py +++ b/client/src/leap/soledad/client/target.py @@ -1149,8 +1149,9 @@ class SoledadSyncTarget(HTTPSyncTarget, TokenBasedAuth): setProxiedObject(self._insert_doc_cb[source_replica_uid], return_doc_cb) + # empty the database before starting a new sync if defer_decryption is True and not self.clear_to_sync(): - raise PendingReceivedDocsSyncError + self._sync_decr_pool.empty() self._ensure_connection() if self._trace_hook: # for tests -- cgit v1.2.3