summaryrefslogtreecommitdiff
path: root/src/driver.rs
diff options
context:
space:
mode:
authorNick Gerace <nickagerace@gmail.com>2021-06-17 23:30:11 -0400
committerNick Gerace <nickagerace@gmail.com>2021-06-17 23:30:11 -0400
commitfb06a0d290ccfb73931db5d139283100bafccbb6 (patch)
tree2064a0bfbed3f7b62e343b4424f79a01fac3981a /src/driver.rs
parentc38c4dfaeab1af89b717ebdcb25bf459daa2a762 (diff)
downloadgfold-fb06a0d290ccfb73931db5d139283100bafccbb6.zip
Continue upon PermissionDenied errors
Diffstat (limited to 'src/driver.rs')
-rw-r--r--src/driver.rs42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/driver.rs b/src/driver.rs
index b01d814..d162275 100644
--- a/src/driver.rs
+++ b/src/driver.rs
@@ -4,7 +4,7 @@ use ansi_term::Style;
use anyhow::{anyhow, Result};
use std::{
cmp::Ordering,
- fs,
+ fs, io,
path::{Path, PathBuf},
};
@@ -84,26 +84,34 @@ impl Driver {
let mut repos: Vec<PathBuf> = Vec::new();
let mut non_repos: Vec<PathBuf> = Vec::new();
- for entry in (fs::read_dir(dir)?).flatten() {
- let file_name_buf = entry.file_name();
- let file_name = match file_name_buf.to_str() {
- Some(o) => o,
- None => continue,
- };
- if !file_name.starts_with('.') && entry.file_type()?.is_dir() {
- let entry_path = entry.path();
- match git2::Repository::open(&entry_path) {
- Ok(_) => repos.push(entry_path),
- Err(_) => {
- if self.config.include_non_repos {
- non_repos.push(entry_path.clone());
- }
- if !self.config.shallow {
- self.execute_in_directory(&entry_path)?;
+ match fs::read_dir(dir) {
+ Ok(o) => {
+ for entry in o.flatten() {
+ let file_name_buf = entry.file_name();
+ let file_name = match file_name_buf.to_str() {
+ Some(o) => o,
+ None => continue,
+ };
+ if !file_name.starts_with('.') && entry.file_type()?.is_dir() {
+ let entry_path = entry.path();
+ match git2::Repository::open(&entry_path) {
+ Ok(_) => repos.push(entry_path),
+ Err(_) => {
+ if self.config.include_non_repos {
+ non_repos.push(entry_path.clone());
+ }
+ if !self.config.shallow {
+ self.execute_in_directory(&entry_path)?;
+ }
+ }
}
}
}
}
+ Err(e) if e.kind() == io::ErrorKind::PermissionDenied => {
+ println!("Permission denied: {}", dir.display())
+ }
+ Err(e) => return Err(e.into()),
}
if !repos.is_empty() {