0.7.22
This commit is contained in:
@@ -152,7 +152,7 @@ impl KbConfig {
|
||||
wallets_directory.display()
|
||||
)));
|
||||
}
|
||||
let sqlite_path = self.data.sqlite_path_buf();
|
||||
let sqlite_path = self.database.sqlite.path_buf();
|
||||
let sqlite_parent_option = sqlite_path.parent();
|
||||
if let Some(sqlite_parent) = sqlite_parent_option {
|
||||
if !sqlite_parent.as_os_str().is_empty() {
|
||||
@@ -509,6 +509,13 @@ pub struct KbSqliteDatabaseConfig {
|
||||
pub use_wal: bool,
|
||||
}
|
||||
|
||||
impl KbSqliteDatabaseConfig {
|
||||
/// Returns the resolved SQLite database path.
|
||||
pub fn path_buf(&self) -> std::path::PathBuf {
|
||||
kb_resolve_workspace_relative_path(&self.path)
|
||||
}
|
||||
}
|
||||
|
||||
/// Database configuration.
|
||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
||||
@@ -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
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user