aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-22 20:43:38 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-22 20:43:38 -0600
commit0ff740af7ea469270ac8f90782e291ce53050f1f (patch)
tree3e360629b3f25904ee8f1d2b7e1cf2dec11b125d /src
parent3905b6ff0c6bdf11290ea8bd1c920b4d14b6f8ca (diff)
downloadgityeet-0ff740af7ea469270ac8f90782e291ce53050f1f.tar.gz
gityeet-0ff740af7ea469270ac8f90782e291ce53050f1f.zip
handle permission errors gracefully
Diffstat (limited to 'src')
-rw-r--r--src/state.rs8
1 files changed, 7 insertions, 1 deletions
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<Path>) -> Result<Vec<Repository>> {
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 {