about summary refs log tree commit diff stats
path: root/src/app.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-23 13:11:09 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-23 13:14:13 +0200
commit94c656ad40a7aae570e5a5fb61ad32632acc6d46 (patch)
tree269614af20caf10d76643c302e0115bd36fd2378 /src/app.rs
parentrefactor(yt_dlp): Also move the `crates` subdirectory (diff)
downloadyt-94c656ad40a7aae570e5a5fb61ad32632acc6d46.tar.gz
yt-94c656ad40a7aae570e5a5fb61ad32632acc6d46.zip
feat(treewide): Use a configuration file
This allows use to avoid duplication of default values in the codebase
and obviously also facilitates changing these without having to
re-compile.
Diffstat (limited to '')
-rw-r--r--src/app.rs14
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,
+        })
     }
 }