diff options
Diffstat (limited to '')
-rw-r--r-- | src/app.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/app.rs b/src/app.rs index f956251..b7d136e 100644 --- a/src/app.rs +++ b/src/app.rs @@ -8,19 +8,20 @@ // You should have received a copy of the License along with this program. // If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. -use std::path::PathBuf; - use anyhow::{Context, Result}; use sqlx::{query, sqlite::SqliteConnectOptions, SqlitePool}; +use crate::config::Config; + pub struct App { pub database: SqlitePool, + pub config: Config, } impl App { - pub async fn new(db_name: PathBuf) -> Result<Self> { + pub async fn new(config: Config) -> Result<Self> { let options = SqliteConnectOptions::new() - .filename(db_name) + .filename(&config.paths.database_path) .optimize_on_close(true, None) .create_if_missing(true); @@ -32,6 +33,9 @@ impl App { .execute(&pool) .await?; - Ok(App { database: pool }) + Ok(App { + database: pool, + config, + }) } } |