X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=backend%2Fsrc%2Fmain.rs;h=a2201d4c8ad5b6efa1e9cd2af0f928721ebdbd66;hb=9deef63b608b62780a4dfed031410c25e10e477a;hp=03963c12a629ea8f4dcfd38216d7189665bf3e4e;hpb=f5ee5c4f340df1843e82b54e8a8835981aef6aa0;p=valheim_web.git diff --git a/backend/src/main.rs b/backend/src/main.rs index 03963c1..a2201d4 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -22,6 +22,7 @@ struct MainTemplate { uptime: String, world_size: String, nb_of_players: u32, + last_backup: String, } const VALUE_UNKNOWN: &str = "-"; @@ -43,11 +44,12 @@ async fn main_page(config_shared: web::Data>) -> impl Responder { load_average: info.format_load_average(), uptime: info.format_uptime(), world_size: info.format_world_size(), - nb_of_players: info.get_nb_of_player() + nb_of_players: info.get_nb_of_player(), + last_backup: info.format_last_backup() }, None => { let value_unknown = String::from(VALUE_UNKNOWN); - MainTemplate { text_status: String::from("Valheim server is down :("), memory: value_unknown.clone(), load_average: value_unknown.clone(), uptime: value_unknown.clone(), world_size: value_unknown.clone(), nb_of_players: 0 } + MainTemplate { text_status: String::from("Valheim server is down :("), memory: value_unknown.clone(), load_average: value_unknown.clone(), uptime: value_unknown.clone(), world_size: value_unknown.clone(), nb_of_players: 0, last_backup: value_unknown.clone() } } } } @@ -55,15 +57,19 @@ async fn main_page(config_shared: web::Data>) -> impl Responder { #[derive(Debug, Deserialize, Serialize)] struct Config { port: u16, + #[serde(default = "empty_string")] world_path: String, + + #[serde(default = "empty_string")] + backup_path: String, } fn empty_string() -> String { "".to_owned() } impl Config { fn default() -> Self { - Config { port: 8082, world_path: String::from("") } + Config { port: 8082, world_path: String::from(""), backup_path: String::from("") } } } @@ -128,7 +134,7 @@ fn process_args(config: &Config) -> bool { print_usage(); return true } else if args.iter().any(|arg| arg == "--status") { - println!("{:?}", valheim_controller::get_valheim_executable_information(&config.world_path)); + println!("{:?}", valheim_controller::get_valheim_executable_information(&config.world_path, &config.backup_path)); return true }