summaryrefslogtreecommitdiff
path: root/client/src/leap
diff options
context:
space:
mode:
authorNavaL <ayoyo@thoughtworks.com>2016-04-29 18:47:13 +0200
committerKali Kaneko <kali@leap.se>2016-06-06 19:58:50 -0400
commitf6a7cdded4285af2335263a058479fa158980b31 (patch)
tree643d74b69f430194bc80acf8d527e6edf4686e72 /client/src/leap
parentebcf2a098fb8e9b1211e31b4955aa67cfebc5854 (diff)
[bug] ensures docs_received table has the sync_id column
For the case where the user already has data synced, this commit will migrate the docs_received table to have the column sync_id. That is required by the refactoring in the previous commits.
Diffstat (limited to 'client/src/leap')
-rw-r--r--client/src/leap/soledad/client/encdecpool.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/client/src/leap/soledad/client/encdecpool.py b/client/src/leap/soledad/client/encdecpool.py
index 7d646c51..e348f545 100644
--- a/client/src/leap/soledad/client/encdecpool.py
+++ b/client/src/leap/soledad/client/encdecpool.py
@@ -369,14 +369,22 @@ class SyncDecrypterPool(SyncEncryptDecryptPool):
def _init_db(self):
"""
+ Ensure sync_id column is present then
Empty the received docs table of the sync database.
:return: A deferred that will fire when the operation in the database
has finished.
:rtype: twisted.internet.defer.Deferred
"""
- query = "DELETE FROM %s WHERE sync_id <> ?" % (self.TABLE_NAME,)
- return self._runOperation(query, (self._sync_id,))
+ ensure_sync_id_column = "ALTER TABLE %s ADD COLUMN sync_id" % self.TABLE_NAME
+ d = self._runQuery(ensure_sync_id_column)
+
+ def empty_received_docs(_):
+ query = "DELETE FROM %s WHERE sync_id <> ?" % (self.TABLE_NAME,)
+ return self._runOperation(query, (self._sync_id,))
+
+ d.addCallbacks(empty_received_docs, empty_received_docs)
+ return d
def _errback(self, failure):
log.err(failure)