Merge pull request #9 from NotAShelf/notashelf/push-klsuwwwrwuqn

stash: create database directory automatically if missing
This commit is contained in:
raf 2025-08-13 17:09:10 +03:00 committed by GitHub
commit 351b98c921
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 2 deletions

2
Cargo.lock generated
View file

@ -953,7 +953,7 @@ dependencies = [
[[package]]
name = "stash"
version = "0.2.2"
version = "0.2.3"
dependencies = [
"base64",
"clap",

View file

@ -1,6 +1,6 @@
[package]
name = "stash"
version = "0.2.2"
version = "0.2.3"
edition = "2024"
authors = ["NotAShelf <raf@notashelf.dev>"]
license = "MPL-2.0"

View file

@ -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);