summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2014-08-04 10:34:20 -0300
committerdrebs <drebs@leap.se>2014-08-08 11:49:03 -0300
commitbb4ef28014b7846df8982f0008635f4d05b5a0b8 (patch)
treecd352e21ed3a94b4e2b358bf6c3e490a33cb8014 /client
parent21a3f854c07c1d40d50da8c922e956d3247a08b2 (diff)
Add instructions for closing SQLCipher db on docstrings.
Diffstat (limited to 'client')
-rw-r--r--client/src/leap/soledad/client/sqlcipher.py37
1 files changed, 36 insertions, 1 deletions
diff --git a/client/src/leap/soledad/client/sqlcipher.py b/client/src/leap/soledad/client/sqlcipher.py
index 85b0391b..7823e235 100644
--- a/client/src/leap/soledad/client/sqlcipher.py
+++ b/client/src/leap/soledad/client/sqlcipher.py
@@ -92,7 +92,16 @@ SQLITE_ISOLATION_LEVEL = None
def open(path, password, create=True, document_factory=None, crypto=None,
raw_key=False, cipher='aes-256-cbc', kdf_iter=4000,
cipher_page_size=1024, defer_encryption=False):
- """Open a database at the given location.
+ """
+ Open a database at the given location.
+
+ *** IMPORTANT ***
+
+ Don't forget to close the database after use by calling the close()
+ method otherwise some resources might not be freed and you may experience
+ several kinds of leakages.
+
+ *** IMPORTANT ***
Will raise u1db.errors.DatabaseDoesNotExist if create=False and the
database does not already exist.
@@ -195,6 +204,14 @@ class SQLCipherDatabase(sqlite_backend.SQLitePartialExpandDatabase):
Connect to an existing SQLCipher database, creating a new sqlcipher
database file if needed.
+ *** IMPORTANT ***
+
+ Don't forget to close the database after use by calling the close()
+ method otherwise some resources might not be freed and you may
+ experience several kinds of leakages.
+
+ *** IMPORTANT ***
+
:param sqlcipher_file: The path for the SQLCipher file.
:type sqlcipher_file: str
:param password: The password that protects the SQLCipher db.
@@ -356,6 +373,14 @@ class SQLCipherDatabase(sqlite_backend.SQLitePartialExpandDatabase):
"""
Open a SQLCipher database.
+ *** IMPORTANT ***
+
+ Don't forget to close the database after use by calling the close()
+ method otherwise some resources might not be freed and you may
+ experience several kinds of leakages.
+
+ *** IMPORTANT ***
+
:param sqlcipher_file: The path for the SQLCipher file.
:type sqlcipher_file: str
@@ -1097,6 +1122,16 @@ class SQLCipherDatabase(sqlite_backend.SQLitePartialExpandDatabase):
del self.sync_queue
self.sync_queue = None
+ def __del__(self):
+ """
+ Free resources when deleting or garbage collecting the database.
+
+ This is only here to minimze problems if someone ever forgets to call
+ the close() method after using the database; you should not rely on
+ garbage collecting to free up the database resources.
+ """
+ self.close()
+
@property
def replica_uid(self):
return self._get_replica_uid()