diff options
author | drebs <drebs@leap.se> | 2013-01-20 16:29:53 -0200 |
---|---|---|
committer | drebs <drebs@leap.se> | 2013-01-20 16:29:53 -0200 |
commit | a2ab7b2b9ca71f7c9fc99f6ddb614d6061c17b81 (patch) | |
tree | 5d6da63cd5843662f6ffa8ec607d6161ced0f760 /backends | |
parent | a2a0800f0edc952f378fc09baf4022393a3fe2a0 (diff) |
SQLCipher backend syncs using a LeapSyncTarget.
Diffstat (limited to 'backends')
-rw-r--r-- | backends/sqlcipher.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/backends/sqlcipher.py b/backends/sqlcipher.py index f7dc6c0b..3d03449e 100644 --- a/backends/sqlcipher.py +++ b/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) |