diff --git a/Cargo.lock b/Cargo.lock index 953ccd3..51bdb68 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -720,7 +720,6 @@ dependencies = [ "anyhow", "axum", "crypto-utils", - "dirs", "hex", "serde", "sqlx", diff --git a/Cargo.toml b/Cargo.toml index df23107..c943d09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,8 @@ members = [ "types", ] resolver = "2" + +[profile.release] +lto = true +opt-level = 'z' +codegen-units = 1 diff --git a/core/src/main.rs b/core/src/main.rs index 5bdd99e..c36bd4f 100644 --- a/core/src/main.rs +++ b/core/src/main.rs @@ -11,11 +11,9 @@ pub const DATABASE_FILE: &str = "homedisk.db"; #[tokio::main] async fn main() { - // initialize logger logger::init(); - // parse config - let config = Config::parse().expect("parse config"); + let config = Config::parse().expect("Failed to parse configuration file"); // open database connection let db = diff --git a/types/Cargo.toml b/types/Cargo.toml index a03309f..405d1d0 100644 --- a/types/Cargo.toml +++ b/types/Cargo.toml @@ -4,7 +4,7 @@ version = "0.0.0" edition = "2021" [features] -config = ["toml", "dirs"] +config = ["toml"] database = ["crypto-utils", "hex", "sqlx"] [dependencies] @@ -14,7 +14,6 @@ anyhow = "1.0.62" serde = { version = "1.0.144", features = ["derive"] } axum = { version = "0.5.15", optional = true } toml = { version = "0.5.9", optional = true } -dirs = { version = "4.0.0", optional = true } crypto-utils = { version = "0.4.0", features = ["sha"], optional = true } hex = { version = "0.4.3", optional = true } sqlx = { version = "0.6.1", features = ["sqlite"], optional = true } diff --git a/types/src/config/types.rs b/types/src/config/types.rs index b897958..918f4be 100644 --- a/types/src/config/types.rs +++ b/types/src/config/types.rs @@ -46,15 +46,10 @@ impl Config { /// let config = Config::parse().unwrap(); /// ``` pub fn parse() -> anyhow::Result { - // get path to the user's config directory - let sys_config_dir = dirs::config_dir().unwrap(); - // path to the homedisk config file - let config_path = format!("{}/homedisk/config.toml", sys_config_dir.to_string_lossy()); + let config = fs::read_to_string("config.toml")?; - // read file content to string - let config = fs::read_to_string(config_path)?; + let serialized = toml::from_str(&config)?; - // parse config and return it - Ok(toml::from_str(&config)?) + Ok(serialized) } }