diff --git a/config.toml b/config.toml index 70717fc..f267db3 100644 --- a/config.toml +++ b/config.toml @@ -1,4 +1,3 @@ -# HTTP Server [http] # HTTP host host = "0.0.0.0" @@ -10,14 +9,12 @@ cors = [ "localhost:8000", ] -# Json Web Token [jwt] # JWT Secret string (used to sign tokens) secret = "secret key used to sign tokens" # Token expiration time in hours -expires = 24 +expires = 24 # one day -# Storage [storage] # Directory where user files will be stored path = "/home/homedisk" diff --git a/core/src/main.rs b/core/src/main.rs index 75416d3..5d18824 100644 --- a/core/src/main.rs +++ b/core/src/main.rs @@ -13,7 +13,7 @@ pub const DATABASE_FILE: &str = "homedisk.db"; async fn main() { logger::init(); - let config = Config::parse().expect("parse config"); + let config = Config::parse().expect("Failed to parse configuration file"); // open database connection let db = @@ -23,26 +23,25 @@ async fn main() { info!("Creating database file..."); // create an empty database file - File::create(DATABASE_FILE).expect("create a database file"); + File::create(DATABASE_FILE).expect("Failed to create a database file"); // open database file let db = Database::open(DATABASE_FILE) .await - .expect("open database file"); + .expect("Failed to open database file"); // create tables in the database db.create_tables() .await - .expect("create tables in the database"); + .expect("Failed to create tables in the database"); db } // if database file exists else { - // open database connection Database::open(DATABASE_FILE) .await - .expect("open database file") + .expect("Failed to open database file") }; // change the type from Vec to Vec so that the http server can correctly detect CORS hosts @@ -60,7 +59,6 @@ async fn main() { port = config.http.port ); - // start http server serve_http(host, origins, db, config) .await .expect("start http server"); diff --git a/types/src/custom_option.rs b/types/src/custom_option.rs deleted file mode 100644 index 5ec4467..0000000 --- a/types/src/custom_option.rs +++ /dev/null @@ -1,13 +0,0 @@ -use std::io; - -/// Custom functions implemented for Option -pub trait OptionOkOrErr { - /// If the value is some return it, if not return Error - fn ok_or_err(self, desc: &str) -> Result; -} - -impl OptionOkOrErr for Option { - fn ok_or_err(self, desc: &str) -> Result { - self.ok_or_else(|| io::Error::new(io::ErrorKind::Other, desc)) - } -} diff --git a/types/src/lib.rs b/types/src/lib.rs index 6444212..51671c9 100644 --- a/types/src/lib.rs +++ b/types/src/lib.rs @@ -2,7 +2,6 @@ pub mod auth; pub mod config; -pub mod custom_option; #[cfg(feature = "database")] pub mod database; pub mod errors;