From 009601e1367b9bafb42e79c531d8570e0fd7c815 Mon Sep 17 00:00:00 2001 From: _ <> Date: Sun, 20 Dec 2020 18:04:19 +0000 Subject: [PATCH] :recycle: refactor: move file server config into file_server --- crates/ptth_file_server_bin/src/main.rs | 9 ++------- crates/ptth_server/src/file_server/mod.rs | 10 +++++++++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/crates/ptth_file_server_bin/src/main.rs b/crates/ptth_file_server_bin/src/main.rs index 561072b..006ca74 100644 --- a/crates/ptth_file_server_bin/src/main.rs +++ b/crates/ptth_file_server_bin/src/main.rs @@ -32,13 +32,8 @@ use ptth_server::{ load_toml, }; -#[derive (Default)] -pub struct Config { - pub file_server_root: Option , -} - struct ServerState <'a> { - config: Config, + config: file_server::Config, handlebars: handlebars::Handlebars <'a>, instance_metrics: metrics::Startup, hidden_path: Option , @@ -112,7 +107,7 @@ async fn main () -> Result <(), anyhow::Error> { debug! ("{:?}", instance_metrics); let state = Arc::new (ServerState { - config: Config { + config: file_server::Config { file_server_root: config_file.file_server_root, }, handlebars, diff --git a/crates/ptth_server/src/file_server/mod.rs b/crates/ptth_server/src/file_server/mod.rs index 78481c4..3c51859 100644 --- a/crates/ptth_server/src/file_server/mod.rs +++ b/crates/ptth_server/src/file_server/mod.rs @@ -9,7 +9,10 @@ use std::{ collections::HashMap, convert::{Infallible, TryFrom}, io::SeekFrom, - path::Path, + path::{ + Path, + PathBuf, + }, }; use handlebars::Handlebars; @@ -53,6 +56,11 @@ mod emoji { pub const ERROR: &str = "\u{26a0}\u{fe0f}"; } +#[derive (Default)] +pub struct Config { + pub file_server_root: Option , +} + #[derive (Serialize)] struct DirEntryJson { name: String,