summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2014-06-05 10:11:13 -0300
committerdrebs <drebs@leap.se>2014-06-05 10:45:29 -0300
commit68443c469e224d93fc36c7c1014191e883edaf67 (patch)
treec2d81187fc88ea04dd18d2262a3d569577846faa /client
parentea2e14430bb26c51611d7c5267489d264caa9bf9 (diff)
Reset synchronizer state in order to reuse the same synchronizer multiple times.
Diffstat (limited to 'client')
-rw-r--r--client/changes/bug_reset-synchronizer-state2
-rw-r--r--client/src/leap/soledad/client/__init__.py1
-rw-r--r--client/src/leap/soledad/client/sqlcipher.py4
3 files changed, 7 insertions, 0 deletions
diff --git a/client/changes/bug_reset-synchronizer-state b/client/changes/bug_reset-synchronizer-state
new file mode 100644
index 00000000..9678b36b
--- /dev/null
+++ b/client/changes/bug_reset-synchronizer-state
@@ -0,0 +1,2 @@
+ o Reset synchronizer state in order to reuse the same synchronizer object
+ multiple times.
diff --git a/client/src/leap/soledad/client/__init__.py b/client/src/leap/soledad/client/__init__.py
index 2fb33184..656c0e77 100644
--- a/client/src/leap/soledad/client/__init__.py
+++ b/client/src/leap/soledad/client/__init__.py
@@ -1065,6 +1065,7 @@ class Soledad(object):
"""
if self._db:
# acquire lock before attempt to sync
+ # TODO: move this lock to inside SQLCipherDatabase.
with Soledad.syncing_lock[self._db._get_replica_uid()]:
local_gen = self._db.sync(
urlparse.urljoin(self.server_url, 'user-%s' % self._uuid),
diff --git a/client/src/leap/soledad/client/sqlcipher.py b/client/src/leap/soledad/client/sqlcipher.py
index 26238af6..576b51ad 100644
--- a/client/src/leap/soledad/client/sqlcipher.py
+++ b/client/src/leap/soledad/client/sqlcipher.py
@@ -401,6 +401,10 @@ class SQLCipherDatabase(sqlite_backend.SQLitePartialExpandDatabase):
creds=creds,
crypto=self._crypto))
self._syncers[url] = (h, syncer)
+ # in order to reuse the same synchronizer multiple times we have to
+ # reset its state (i.e. the number of documents received from target
+ # and inserted in the local replica).
+ syncer.num_inserted = 0
return syncer
def _extra_schema_init(self, c):