|
|
@ -4,6 +4,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "sqlite")]
|
|
|
|
#[cfg(feature = "sqlite")]
|
|
|
|
use std::fs::create_dir_all;
|
|
|
|
use std::fs::create_dir_all;
|
|
|
|
|
|
|
|
use std::path::Path;
|
|
|
|
|
|
|
|
|
|
|
|
use indexmap::IndexMap;
|
|
|
|
use indexmap::IndexMap;
|
|
|
|
use serde_json::Value as JsonValue;
|
|
|
|
use serde_json::Value as JsonValue;
|
|
|
@ -76,6 +77,11 @@ impl DbPool {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#[cfg(feature = "sqlite")]
|
|
|
|
#[cfg(feature = "sqlite")]
|
|
|
|
"sqlite" => {
|
|
|
|
"sqlite" => {
|
|
|
|
|
|
|
|
let conn_url = if Path::new(conn_url).is_absolute() {
|
|
|
|
|
|
|
|
create_dir_all(conn_url).expect("Couldn't create dir");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conn_url
|
|
|
|
|
|
|
|
} else {
|
|
|
|
let app_path = _app
|
|
|
|
let app_path = _app
|
|
|
|
.path()
|
|
|
|
.path()
|
|
|
|
.app_config_dir()
|
|
|
|
.app_config_dir()
|
|
|
@ -83,7 +89,8 @@ impl DbPool {
|
|
|
|
|
|
|
|
|
|
|
|
create_dir_all(&app_path).expect("Couldn't create app config dir");
|
|
|
|
create_dir_all(&app_path).expect("Couldn't create app config dir");
|
|
|
|
|
|
|
|
|
|
|
|
let conn_url = &path_mapper(app_path, conn_url);
|
|
|
|
&path_mapper(app_path, conn_url)
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if !Sqlite::database_exists(conn_url).await.unwrap_or(false) {
|
|
|
|
if !Sqlite::database_exists(conn_url).await.unwrap_or(false) {
|
|
|
|
Sqlite::create_database(conn_url).await?;
|
|
|
|
Sqlite::create_database(conn_url).await?;
|
|
|
|