Fix saving the new key to the settings if the 'remember key' option was set and the DB was rekeyed

This commit is contained in:
Miguel Jacq 2025-11-03 12:39:31 +11:00
parent 329e016f8d
commit ba6417e72f
Signed by: mig5
GPG key ID: 59B3F0C24135C6A9
3 changed files with 10 additions and 1 deletions

View file

@ -1,3 +1,11 @@
# 0.1.8
* Fix saving the new key to the settings if the 'remember key' option was set and the DB was rekeyed
# 0.1.7
* More fixes for shortcuts and move the Change Key button in settings
# 0.1.6 # 0.1.6
* Fix shortcuts for next/previous day to not collide with Normal text (Ctrl+N) * Fix shortcuts for next/previous day to not collide with Normal text (Ctrl+N)

View file

@ -133,7 +133,7 @@ class DBManager:
raise RuntimeError("Database is not connected") raise RuntimeError("Database is not connected")
cur = self.conn.cursor() cur = self.conn.cursor()
# Change the encryption key of the currently open database # Change the encryption key of the currently open database
cur.execute(f"PRAGMA rekey = '{new_key}';") cur.execute(f"PRAGMA rekey = '{new_key}';").fetchone()
self.conn.commit() self.conn.commit()
# Close and reopen with the new key to verify and restore PRAGMAs # Close and reopen with the new key to verify and restore PRAGMAs

View file

@ -180,6 +180,7 @@ class SettingsDialog(QDialog):
QMessageBox.warning(self, "Empty key", "Key cannot be empty.") QMessageBox.warning(self, "Empty key", "Key cannot be empty.")
return return
try: try:
self.key = new_key
self._db.rekey(new_key) self._db.rekey(new_key)
QMessageBox.information( QMessageBox.information(
self, "Key changed", "The notebook was re-encrypted with the new key!" self, "Key changed", "The notebook was re-encrypted with the new key!"