summaryrefslogtreecommitdiff
path: root/src/leap/soledad/backends/sqlcipher.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-01-24 12:03:45 -0200
committerdrebs <drebs@leap.se>2013-01-24 12:03:45 -0200
commite1494639f57cafddfd433c62adaa52a21f104e10 (patch)
treeb9e6b700db7ab9d9b3f927222eb0f780e7c851d8 /src/leap/soledad/backends/sqlcipher.py
parent19da34c598ce6db172c1e1a8978bf031fc6db89b (diff)
parent1dec55b5c5054a4c42534c0f7e9b8bad5b82c27c (diff)
Merge branch 'feature/soledad-api' into develop
Conflicts: src/leap/soledad/util.py
Diffstat (limited to 'src/leap/soledad/backends/sqlcipher.py')
-rw-r--r--src/leap/soledad/backends/sqlcipher.py16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/leap/soledad/backends/sqlcipher.py b/src/leap/soledad/backends/sqlcipher.py
index 3d03449e..08b4df43 100644
--- a/src/leap/soledad/backends/sqlcipher.py
+++ b/src/leap/soledad/backends/sqlcipher.py
@@ -59,11 +59,9 @@ class SQLCipherDatabase(SQLitePartialExpandDatabase):
_index_storage_value = 'expand referenced encrypted'
-
@classmethod
def set_pragma_key(cls, db_handle, key):
- db_handle.cursor().execute("PRAGMA key = '%s'" % key)
-
+ db_handle.cursor().execute("PRAGMA key = '%s'" % key)
def __init__(self, sqlite_file, password, document_factory=None):
"""Create a new sqlcipher file."""
@@ -74,20 +72,18 @@ class SQLCipherDatabase(SQLitePartialExpandDatabase):
self._ensure_schema()
self._factory = document_factory or Document
-
def _check_if_db_is_encrypted(self, sqlite_file):
if not os.path.exists(sqlite_file):
return
else:
try:
- # try to open an encrypted database with the regular u1db backend
- # should raise a DatabaseError exception.
+ # try to open an encrypted database with the regular u1db
+ # backend should raise a DatabaseError exception.
SQLitePartialExpandDatabase(sqlite_file)
raise DatabaseIsNotEncrypted()
except DatabaseError:
pass
-
@classmethod
def _open_database(cls, sqlite_file, password, document_factory=None):
if not os.path.isfile(sqlite_file):
@@ -113,7 +109,6 @@ class SQLCipherDatabase(SQLitePartialExpandDatabase):
return SQLCipherDatabase._sqlite_registry[v](
sqlite_file, password, document_factory=document_factory)
-
@classmethod
def open_database(cls, sqlite_file, password, create, backend_cls=None,
document_factory=None):
@@ -129,7 +124,6 @@ class SQLCipherDatabase(SQLitePartialExpandDatabase):
return backend_cls(sqlite_file, password,
document_factory=document_factory)
-
def sync(self, url, creds=None, autocreate=True, soledad=None):
"""
Synchronize encrypted documents with remote replica exposed at url.
@@ -137,9 +131,7 @@ class SQLCipherDatabase(SQLitePartialExpandDatabase):
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)
+ soledad=self._soledad).sync(autocreate=autocreate)
SQLiteDatabase.register_implementation(SQLCipherDatabase)
-