summaryrefslogtreecommitdiff
path: root/client/src/leap/soledad
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2014-07-23 10:29:39 -0300
committerdrebs <drebs@leap.se>2014-08-08 11:49:02 -0300
commit8afb79c4d2171b03270143639296cbb6d9d0fdfa (patch)
tree1ad4f1d1d9bd3e9366827caa86fa4792db0c0e9e /client/src/leap/soledad
parent5e4dae3427f40879156ddfaaaa8f878ab2504ee3 (diff)
Allow deferred decryption without deferred encryption.
Diffstat (limited to 'client/src/leap/soledad')
-rw-r--r--client/src/leap/soledad/client/sqlcipher.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/client/src/leap/soledad/client/sqlcipher.py b/client/src/leap/soledad/client/sqlcipher.py
index 2df9606e..5a30b125 100644
--- a/client/src/leap/soledad/client/sqlcipher.py
+++ b/client/src/leap/soledad/client/sqlcipher.py
@@ -243,19 +243,14 @@ class SQLCipherDatabase(sqlite_backend.SQLitePartialExpandDatabase):
self._ensure_schema()
self._crypto = crypto
+ # define sync-db attrs
self._sync_db = None
self._sync_db_write_lock = None
self._sync_enc_pool = None
+ self._init_sync_db(sqlcipher_file)
if self.defer_encryption:
- if sqlcipher_file != ":memory:":
- self._sync_db_path = "%s-sync" % sqlcipher_file
- else:
- self._sync_db_path = ":memory:"
-
# initialize sync db
- self._init_sync_db()
-
# initialize syncing queue encryption pool
self._sync_enc_pool = SyncEncrypterPool(
self._crypto, self._sync_db, self._sync_db_write_lock)
@@ -449,7 +444,6 @@ class SQLCipherDatabase(sqlite_backend.SQLitePartialExpandDatabase):
# the following context manager blocks until the syncing lock can be
# acquired.
with self.syncer(url, creds=creds) as syncer:
-
# XXX could mark the critical section here...
try:
res = syncer.sync(autocreate=autocreate,
@@ -542,14 +536,21 @@ class SQLCipherDatabase(sqlite_backend.SQLitePartialExpandDatabase):
'ALTER TABLE document '
'ADD COLUMN syncable BOOL NOT NULL DEFAULT TRUE')
- def _init_sync_db(self):
+ def _init_sync_db(self, sqlcipher_file):
"""
Initialize the Symmetrically-Encrypted document to be synced database,
and the queue to communicate with subprocess workers.
+
+ :param sqlcipher_file: The path for the SQLCipher file.
+ :type sqlcipher_file: str
"""
- self._sync_db = sqlite3.connect(self._sync_db_path,
+ sync_db_path = None
+ if sqlcipher_file != ":memory:":
+ sync_db_path = "%s-sync" % sqlcipher_file
+ else:
+ sync_db_path = ":memory:"
+ self._sync_db = sqlite3.connect(sync_db_path,
check_same_thread=False)
-
self._sync_db_write_lock = threading.Lock()
self._create_sync_db_tables()
self.sync_queue = multiprocessing.Queue()