Skip to content

Commit

Permalink
create directory for db dir torii
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Nov 13, 2024
1 parent f9523ee commit d6b3b67
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bin/torii/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,14 @@ async fn main() -> anyhow::Result<()> {
.expect("Error setting Ctrl-C handler");

let tempfile = NamedTempFile::new()?;
let database_path =
if let Some(db_dir) = args.db_dir { db_dir } else { tempfile.path().to_path_buf() };
let database_path = if let Some(db_dir) = args.db_dir {
// Create the directory if it doesn't exist
std::fs::create_dir_all(&db_dir)?;
// Set the database file path inside the directory
db_dir.join("torii.db")
} else {
tempfile.path().to_path_buf()
};

let mut options = SqliteConnectOptions::from_str(&database_path.to_string_lossy())?
.create_if_missing(true)
Expand Down

0 comments on commit d6b3b67

Please sign in to comment.