diff --git a/src/main.rs b/src/main.rs index 7bac30a..d4af63e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -67,14 +67,30 @@ fn get_dokku_root() -> Option { None } +fn osstring_starts_with(data: std::ffi::OsString, prefix: char) -> bool { + match data.into_string() { + Ok(s) => matches!(s.chars().next(), Some(c) if c == prefix), + Err(_) => false, + } +} + async fn hosts(State(state): State) -> axum::Json> { let mut dir_entries = state.dokku_root.read_dir().await.unwrap(); let mut join_set = JoinSet::new(); while let Some(Ok(dir_entry)) = dir_entries.next().await { + // Skip hidden folders / files + if osstring_starts_with(dir_entry.file_name(), '.') { + continue; + } + let path = dir_entry.path(); + if !path.is_dir().await { + continue; + } + join_set.spawn(DokkuApp::try_from_path(path)); }