diff --git a/src/repos.rs b/src/repos.rs index 421bc06..3f64302 100644 --- a/src/repos.rs +++ b/src/repos.rs @@ -54,12 +54,24 @@ pub fn find_repos(config: &Config) -> Result>> { repos.insert(session.name.clone(), vec![session]); } } else if file.path.is_dir() && file.depth > 0 { - let read_dir = fs::read_dir(&file.path) - .change_context(TmsError::IoError) - .attach_printable_lazy(|| format!("Could not read directory {:?}", file.path))? - .map(|dir_entry| dir_entry.expect("Found non-valid utf8 path").path()); - for dir in read_dir { - to_search.push_back(SearchDirectory::new(dir, file.depth - 1)) + match fs::read_dir(&file.path) { + Err(ref e) if e.kind() == std::io::ErrorKind::PermissionDenied => { + eprintln!( + "Warning: insufficient permissions to read '{0}'. Skipping directory...", + file.path.to_string()? + ); + } + result => { + let read_dir = result + .change_context(TmsError::IoError) + .attach_printable_lazy(|| { + format!("Could not read directory {:?}", file.path) + })? + .map(|dir_entry| dir_entry.expect("Found non-valid utf8 path").path()); + for dir in read_dir { + to_search.push_back(SearchDirectory::new(dir, file.depth - 1)) + } + } } } }