summaryrefslogtreecommitdiff
path: root/src/leap/soledad/backends
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-01-20 16:29:53 -0200
committerdrebs <drebs@leap.se>2013-01-20 16:29:53 -0200
commiteae9fd4b5d93845fc708abb722714ebf9d003418 (patch)
tree9f1bd621c2f832a470d27eaab71fbd8629862e51 /src/leap/soledad/backends
parentc1e460cc15523a0138dde1ece9d584554d99c04b (diff)
SQLCipher backend syncs using a LeapSyncTarget.
Diffstat (limited to 'src/leap/soledad/backends')
-rw-r--r--src/leap/soledad/backends/sqlcipher.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/leap/soledad/backends/sqlcipher.py b/src/leap/soledad/backends/sqlcipher.py
index f7dc6c0b..3d03449e 100644
--- a/src/leap/soledad/backends/sqlcipher.py
+++ b/src/leap/soledad/backends/sqlcipher.py
@@ -20,14 +20,17 @@ import os
from sqlite3 import dbapi2, DatabaseError
import time
-from u1db.backends.sqlite_backend import SQLitePartialExpandDatabase
+from u1db.backends.sqlite_backend import (
+ SQLiteDatabase,
+ SQLitePartialExpandDatabase,
+)
from u1db import (
Document,
errors,
)
-def open(path, password, create, document_factory=None):
+def open(path, password, create=True, document_factory=None):
"""Open a database at the given location.
Will raise u1db.errors.DatabaseDoesNotExist if create=False and the
@@ -127,13 +130,15 @@ class SQLCipherDatabase(SQLitePartialExpandDatabase):
document_factory=document_factory)
- @staticmethod
- def register_implementation(klass):
- """Register that we implement an SQLCipherDatabase.
-
- The attribute _index_storage_value will be used as the lookup key.
+ def sync(self, url, creds=None, autocreate=True, soledad=None):
+ """
+ Synchronize encrypted documents with remote replica exposed at url.
"""
- SQLCipherDatabase._sqlite_registry[klass._index_storage_value] = klass
+ from u1db.sync import Synchronizer
+ from leap.soledad.backends.leap_backend import LeapSyncTarget
+ return Synchronizer(self, LeapSyncTarget(url, creds=creds),
+ soledad=self._soledad).sync(
+ autocreate=autocreate)
SQLiteDatabase.register_implementation(SQLCipherDatabase)