Add the ability to choose the database path at startup. Add more tests. Add bandit
All checks were successful
CI / test (push) Successful in 3m49s
Lint / test (push) Successful in 29s
Trivy / test (push) Successful in 21s

This commit is contained in:
Miguel Jacq 2025-11-17 15:15:00 +11:00
parent 8c7226964a
commit 6bc5b66d3f
Signed by: mig5
GPG key ID: 59B3F0C24135C6A9
16 changed files with 297 additions and 97 deletions

View file

@ -329,14 +329,14 @@ class MainWindow(QMainWindow):
try:
self.db = DBManager(self.cfg)
ok = self.db.connect()
return ok
except Exception as e:
if str(e) == "file is not a database":
error = strings._("db_key_incorrect")
else:
error = str(e)
QMessageBox.critical(self, strings._("db_database_error"), error)
return False
return ok
sys.exit(1)
def _prompt_for_key_until_valid(self, first_time: bool) -> bool:
"""
@ -349,10 +349,20 @@ class MainWindow(QMainWindow):
title = strings._("unlock_encrypted_notebook")
message = strings._("unlock_encrypted_notebook_explanation")
while True:
dlg = KeyPrompt(self, title, message)
dlg = KeyPrompt(
self, title, message, initial_db_path=self.cfg.path, show_db_change=True
)
if dlg.exec() != QDialog.Accepted:
return False
self.cfg.key = dlg.key()
# Update DB path if the user changed it
new_path = dlg.db_path()
if new_path is not None and new_path != self.cfg.path:
self.cfg.path = new_path
# Persist immediately so next run is pre-filled with this file
save_db_config(self.cfg)
if self._try_connect():
return True