This commit is contained in:
2026-05-01 00:29:32 +02:00
parent b3b0e882b2
commit c542aa9d32
17 changed files with 2347 additions and 49 deletions

View File

@@ -12,7 +12,8 @@ pub(crate) fn sqlite_database_url_from_config(
"database.sqlite.path must not be empty".to_string(),
));
}
Ok(format!("sqlite://{}", path))
let database_path = config.sqlite.path_buf();
Ok(format!("sqlite://{}", database_path.display()))
}
/// Opens a SQLite pool according to configuration.
@@ -30,7 +31,7 @@ pub(crate) async fn connect_sqlite(
"database.sqlite.max_connections must be > 0".to_string(),
));
}
let database_path = std::path::Path::new(path);
let database_path = config.sqlite.path_buf();
let parent_option = database_path.parent();
if let Some(parent) = parent_option {
if !parent.as_os_str().is_empty() {
@@ -45,7 +46,7 @@ pub(crate) async fn connect_sqlite(
}
}
let mut connect_options = sqlx::sqlite::SqliteConnectOptions::new()
.filename(database_path)
.filename(&database_path)
.create_if_missing(config.sqlite.create_if_missing)
.foreign_keys(true)
.busy_timeout(std::time::Duration::from_millis(
@@ -61,7 +62,7 @@ pub(crate) async fn connect_sqlite(
Ok(pool) => Ok(pool),
Err(error) => Err(crate::KbError::Db(format!(
"cannot open sqlite database '{}': {}",
path, error
database_path.display(), error
))),
}
}