[almanah] Bug 580052 – Not encrypting keeps encrypted database
- From: Philip Withnall <pwithnall src gnome org>
- To: svn-commits-list gnome org
- Subject: [almanah] Bug 580052 – Not encrypting keeps encrypted database
- Date: Sun, 3 May 2009 10:54:48 -0400 (EDT)
commit 0b17724a31e91a6ced6763ceddeae6e57c8fbaa9
Author: Philip Withnall <philip tecnocode co uk>
Date: Sun May 3 15:52:55 2009 +0100
Bug 580052 â?? Not encrypting keeps encrypted database
Delete the old encrypted database if closing a database which wasn't
initially encrypted, or without an encryption key.
---
src/storage-manager.c | 22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/storage-manager.c b/src/storage-manager.c
index 4d22da0..eebb10f 100644
--- a/src/storage-manager.c
+++ b/src/storage-manager.c
@@ -545,19 +545,15 @@ almanah_storage_manager_disconnect (AlmanahStorageManager *self, GError **error)
sqlite3_close (self->priv->connection);
#ifdef ENABLE_ENCRYPTION
- /* If the database wasn't encrypted before we opened it, we won't encrypt it when closing */
- if (self->priv->decrypted == FALSE) {
- g_signal_emit (self, storage_manager_signals[SIGNAL_DISCONNECTED], 0, NULL, NULL);
- return TRUE;
- }
+ /* If the database wasn't encrypted before we opened it, we won't encrypt it when closing.
+ * In fact, we'll go so far as to delete the old encrypted database file. */
+ if (self->priv->decrypted == FALSE)
+ goto delete_encrypted_db;
/* Get the encryption key */
encryption_key = get_encryption_key ();
- if (encryption_key == NULL) {
- /* The preferences are set to not encrypt the diary */
- g_signal_emit (self, storage_manager_signals[SIGNAL_DISCONNECTED], 0, NULL, NULL);
- return TRUE;
- }
+ if (encryption_key == NULL)
+ goto delete_encrypted_db;
/* Encrypt the plain DB file */
if (encrypt_database (self, encryption_key, &child_error) != TRUE) {
@@ -578,6 +574,12 @@ almanah_storage_manager_disconnect (AlmanahStorageManager *self, GError **error)
#endif /* !ENABLE_ENCRYPTION */
return TRUE;
+
+delete_encrypted_db:
+ /* Delete the old encrypted database and return */
+ g_unlink (self->priv->filename);
+ g_signal_emit (self, storage_manager_signals[SIGNAL_DISCONNECTED], 0, NULL, NULL);
+ return TRUE;
}
AlmanahQueryResults *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]