From db6a962c7598b82b66093858b51baba5d1c6ab9e Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 13 Aug 2025 17:05:18 +0300 Subject: [PATCH] stash: create database directory automatically if missing Oops. Signed-off-by: NotAShelf Change-Id: I6a6a6964866a1711971322c81ea194aa062466da --- src/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main.rs b/src/main.rs index 0e8128f..f41ccac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -107,6 +107,13 @@ fn main() { .join("db") }); + if let Some(parent) = db_path.parent() { + if let Err(e) = std::fs::create_dir_all(parent) { + log::error!("Failed to create database directory: {e}"); + process::exit(1); + } + } + let conn = rusqlite::Connection::open(&db_path).unwrap_or_else(|e| { log::error!("Failed to open SQLite database: {e}"); process::exit(1);