From 0ff740af7ea469270ac8f90782e291ce53050f1f Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Thu, 22 Apr 2021 20:43:38 -0600 Subject: handle permission errors gracefully --- src/state.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/state.rs b/src/state.rs index 645a4b6..ed7f196 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1,4 +1,5 @@ use std::fs::read_dir; +use std::io; use std::path::{Path, PathBuf}; use eyre::Result; @@ -13,7 +14,12 @@ pub struct State { // Heartbreaking: E0733 fn find_repos_in(dir: impl AsRef) -> Result> { let dir = dir.as_ref(); - let dir = read_dir(dir)?; + let dir = read_dir(dir); + let dir = match dir { + Ok(x) => x, + Err(err) if err.kind() == io::ErrorKind::PermissionDenied => return Ok(vec![]), + Err(err) => Err(err)?, + }; let mut result = vec![]; for subdir in dir { if let Ok(subdir) = subdir { -- cgit v1.2.3