From 136b42918f09a527653e4535fbee096a29e13309 Mon Sep 17 00:00:00 2001 From: august kline Date: Thu, 14 Nov 2024 12:19:14 -0500 Subject: [PATCH] Going back to relative urls, this was a systemd problem --- src/lib.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c57dc7b..786eff0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,11 +17,6 @@ use sqlx::{ SqlitePool, }; -// #[cfg(not(debug_assertions))] -// const CACHE_URL: &str = "sqlite://:memory:"; -// #[cfg(debug_assertions)] -const CACHE_URL: &str = "cache.db"; - /// A Sqlite database for all blog data. /// /// It uses a file-backed db for posts, drafts, users, and assets, and an in-memory db for cached @@ -38,8 +33,8 @@ impl BlogDb { where S: AsRef, { - let main_db_name = dotenvy::var("DB_MAIN_PATH")?; - let cache_name = dotenvy::var("DB_CACHE_PATH")?; + let main_db_name = dotenvy::var("DB_MAIN_PATH").unwrap_or("main.db".to_string()); + let cache_name = dotenvy::var("DB_CACHE_PATH").unwrap_or("cache.db".to_string()); if File::open(&main_db_name).is_err() { File::create_new(&main_db_name)?; } @@ -48,7 +43,7 @@ impl BlogDb { } let db = SqlitePoolOptions::new() .connect_with( - SqliteConnectOptions::from_str(&["sqlite:///", &main_db_name].concat())? + SqliteConnectOptions::from_str(&["sqlite://", &main_db_name].concat())? .journal_mode(SqliteJournalMode::Wal), ) .await?; @@ -58,7 +53,7 @@ impl BlogDb { // #[cfg(not(debug_assertions))] // SqliteConnectOptions::from_str(MEMORY_URL)?.journal_mode(SqliteJournalMode::Memory), // #[cfg(debug_assertions)] - SqliteConnectOptions::from_str(&["sqlite:///", &cache_name].concat())? + SqliteConnectOptions::from_str(&["sqlite://", &cache_name].concat())? .journal_mode(SqliteJournalMode::Wal), ) .await?;