diff options
Diffstat (limited to 'src/projects.rs')
-rw-r--r-- | src/projects.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/projects.rs b/src/projects.rs index 23530a7..8819628 100644 --- a/src/projects.rs +++ b/src/projects.rs @@ -2,7 +2,7 @@ use crate::{Config, Result}; use figment::Provider; use ignore::Walk; use std::{path::PathBuf, vec::IntoIter}; -use tracing::warn; +use tracing::{error, info}; pub use entry::SearchPath; @@ -54,16 +54,15 @@ impl Iterator for Projects { #[tracing::instrument] fn next(&mut self) -> Option<Self::Item> { - if self.walk.is_none() { - self.walk = Some(self.search_path_iter.next()?.into()); - }; - - match self.walk.as_mut()?.next()? { - Ok(d) => Some(d.into_path()), - Err(err) => { - warn!("{:?}", err); - None - } + loop { + match self.walk.as_mut().and_then(|iter| iter.next()) { + Some(Ok(path)) if SearchPath::filter(&path) => return Some(path.into_path()), + Some(Ok(path)) => info!(?path, "Ignoring filtered path"), + Some(Err(err)) => error!(%err, "Ignoring errored path"), + None => { + self.walk = Some(self.search_path_iter.next()?.into()); + } + }; } } } |