From d8c5113084156414ffd9aa4014754360740569de Mon Sep 17 00:00:00 2001 From: "Xql.dev" <205849173+KirobotDev@users.noreply.github.com> Date: Sun, 6 Sep 2026 01:09:38 +0700 Subject: [PATCH] Fix silent save failures and list crash on fresh clone Ensure the secret/ directory is created before opening the database or writing password files, so a fresh clone (where secret/ is gitignored) does not fail. - commands/add.py: os.makedirs('./secret', exist_ok=True) before sqlite3.connect, so save (opt 1) no longer silently fails and list (opt 2) no longer crashes with 'unable to open database file'. - japanese/commands/add.py: same guard before writing password files. Closes #8 --- commands/add.py | 3 ++- japanese/commands/add.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/commands/add.py b/commands/add.py index 7a68587..757c26d 100644 --- a/commands/add.py +++ b/commands/add.py @@ -58,7 +58,8 @@ def add_passwd() -> str: encrypted = fernet.encrypt(passwd.encode()) print(f"Encrypted password: {encrypted}") - + + os.makedirs("./secret", exist_ok=True) conn = sqlite3.connect("./secret/passwords.db") cursor = conn.cursor() diff --git a/japanese/commands/add.py b/japanese/commands/add.py index 715a574..0bcec67 100644 --- a/japanese/commands/add.py +++ b/japanese/commands/add.py @@ -51,6 +51,7 @@ def パスワード追加() -> str: 暗号文 = 暗号器.encrypt(パスワード.encode()) print(f"暗号化されたパスワード : {暗号文}") + os.makedirs("./secret", exist_ok=True) with open(f"./secret/{サイト名}.txt", "a", encoding="utf-8") as ファイル: ファイル.write(f"{暗号文.decode()}\n")