12
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/main.rs
									
									
									
									
									
								
							| @@ -1,8 +1,6 @@ | ||||
| use structopt::StructOpt; | ||||
| use std::{ | ||||
|     path::PathBuf, | ||||
|     fs::File, | ||||
|     io::prelude::*, | ||||
|     boxed::Box, | ||||
|     error::Error, | ||||
| }; | ||||
| @@ -20,6 +18,8 @@ use sqlx::{ | ||||
| }; | ||||
| use tokio::{ | ||||
|     sync::RwLock, | ||||
|     fs::File, | ||||
|     io::AsyncReadExt, | ||||
| }; | ||||
|  | ||||
| const DEFAULT_DATABASE_PATH: &'static str = "/var/lib/noise-server/noise-server.sqlite"; | ||||
| @@ -67,7 +67,7 @@ async fn main() -> Result<(), Box<dyn Error>> { | ||||
|         return Ok(()); | ||||
|     } | ||||
|  | ||||
|     let mut config = get_config(&options)?; | ||||
|     let mut config = get_config(&options).await?; | ||||
|  | ||||
|     if clap_matches.is_present("database-path") { | ||||
|         config.database_path = options.database_path; | ||||
| @@ -106,13 +106,13 @@ async fn load_sqlite_template(sqlite_handle: &mut SqliteConnection) -> sqlx::Res | ||||
|     )).execute(sqlite_handle).await | ||||
| } | ||||
|  | ||||
| fn get_config(options: &Options) -> std::io::Result<Config> { | ||||
| async fn get_config(options: &Options) -> std::io::Result<Config> { | ||||
|     if options.no_config { | ||||
|         Ok(Config::default()) | ||||
|     } else { | ||||
|         let mut config_file = File::open(&options.config)?; | ||||
|         let mut config_file = File::open(&options.config).await?; | ||||
|         let mut config_string = String::new(); | ||||
|         config_file.read_to_string(&mut config_string)?; | ||||
|         config_file.read_to_string(&mut config_string).await?; | ||||
|  | ||||
|         toml::from_str(&config_string) | ||||
|             .map_err(|err| std::io::Error::new( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user