From aaa9d542b648ff2393533319a2105a5e57cb8971 Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Tue, 27 May 2025 22:38:31 -0400 Subject: [PATCH] Added function to create file for database if one does not exist --- src/main.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main.rs b/src/main.rs index 794001f..5f8e9b5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,8 @@ mod cli; mod db; +use std::{fs::File, path::Path}; + use anyhow::anyhow; use clap::Parser; use cli::Cli; @@ -16,6 +18,15 @@ async fn main() -> Result<()> { Please provide one with the BOOKMARK_DB_PATH environment \ variable.".to_string() ))?; + create_if_not_exists(&location)?; let store = db::Store::new(&location, cli.is_reading_list).await?; cli.run(store).await } + +fn create_if_not_exists(path_string: &str) -> Result<()> { + let path = Path::new(path_string); + if !path.is_file() { + File::create(path)?; + } + Ok(()) +}