disable browser/ui serving if folder not found

feat/vaults
Tomáš Mládek 2021-12-04 22:43:37 +01:00
parent 6bc4e7ffce
commit 636da63c76
1 changed files with 6 additions and 8 deletions

View File

@ -104,7 +104,11 @@ fn main() -> Result<()> {
};
// Start HTTP server
let ui_enabled = !matches.is_present("NO_UI");
let ui_path = env::current_exe().unwrap().parent().unwrap().join("webui");
if !ui_path.exists() {
warn!("No Web UI directory present ({:?}), disabling...", ui_path);
}
let ui_enabled = ui_path.exists() && !matches.is_present("NO_UI");
HttpServer::new(move || {
let app = App::new()
.data(state.clone())
@ -122,13 +126,7 @@ fn main() -> Result<()> {
.service(routes::get_info);
if ui_enabled {
app.service(
actix_files::Files::new(
"/",
env::current_exe().unwrap().parent().unwrap().join("webui"),
)
.index_file("index.html"),
)
app.service(actix_files::Files::new("/", &ui_path).index_file("index.html"))
} else {
app
}