Print errors when --verbose is set
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Park Juhyung · committed by David Peter · parent f7a96bd · Browse files · 5 files·+19 added−3 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+19 added−3 removed
- other:+19 added−3 removed
Provenance
- Commit
095bad5- Tree
3de256d- Author
Park Juhyung <majecty@gmail.com>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
f7a96bd
5 files changed+19 added−3 removed
modified:src/exec/job.rs+4 added-1 removed
17 unmodified lines18 pub fn job(19 rx: Arc<Mutex<Receiver<WorkerResult>>>,20 cmd: Arc<CommandTemplate>,21 out_perm: Arc<Mutex<()>>,22+ show_filesystem_errors: bool,23 ) {24 loop {25 // Create a lock on the shared receiver for this thread.26 let lock = rx.lock().unwrap();2 unmodified lines29 // has closed, exit from the loop30 let value: PathBuf = match lock.recv() {31 Ok(WorkerResult::Entry(val)) => val,32 Ok(WorkerResult::Error(err)) => {33+ if show_filesystem_errors {32- print_error!("{}", err);34+ print_error!("{}", err);35+ }36 continue;37 }38 Err(_) => break,39 };7 unmodified linesmodified:src/internal/opts.rs+3 added
70 unmodified lines71 pub size_constraints: Vec<SizeFilter>,72 73 /// Constraints on last modification time of files74 pub time_constraints: Vec<TimeFilter>,75+76+ /// Whether or not to display filesystem errors77+ pub show_filesystem_errors: bool,78 }modified:src/app.rs+5 added
179 unmodified lines180 .long("changed-before")181 .takes_value(true)182 .number_of_values(1),183 )184+ .arg(arg("show-errors").long("show-errors"))185 .arg(arg("pattern"))186 .arg(arg("path").multiple(true))187 .arg(188 arg("search-path")133 unmodified lines322 , "Limit results based on modification time within the duration provided or between date provided and now."323 , "Limit results based on modification time within the duration provided:\n \324 using a duration: <NUM>d <NUM>h <NUM>m <NUM>s (e.g. 10h, 1d, 35min...)\n \325 or a date and time: YYYY-MM-DD HH:MM:SS");326+ doc!(h, "show-errors"327+ , "Enable display of filesystem errors"328+ , "Enable the display of filesystem errors for situations such as insufficient permissions \329+ or dead symlinks.");330 doc!(h, "search-path"331 , "Provide paths to search as flag arguments rather than positional arguments."332 , "Provide paths to search as flag arguments, preventing the usage of any positional `path` arugments.\n\333 Changes the usage to `fd [FLAGS/OPTIONS] --search-path <path> --search-path <path2> [<pattern>]`");2 unmodified linesmodified:src/main.rs+1 added
251 unmodified lines252 .map(|vs| vs.map(PathBuf::from).collect())253 .unwrap_or_else(|| vec![]),254 size_constraints: size_limits,255 time_constraints,256+ show_filesystem_errors: matches.is_present("show-errors"),257 };258 259 match RegexBuilder::new(&pattern_regex)260 .case_insensitive(!config.case_sensitive)13 unmodified linesmodified:src/walk.rs+6 added-2 removed
53 unmodified lines54 .next()55 .expect("Error: Path vector can not be empty");56 let (tx, rx) = channel();57 let threads = config.threads;58+ let show_filesystem_errors = config.show_filesystem_errors;59 60 let mut override_builder = OverrideBuilder::new(first_path_buf.as_path());61 62 for pattern in &config.exclude_patterns {80 unmodified lines143 let cmd = Arc::clone(&cmd);144 let out_perm = Arc::clone(&out_perm);145 146 // Spawn a job thread that will listen for and execute inputs.146- let handle = thread::spawn(move || exec::job(rx, cmd, out_perm));147+ let handle =148+ thread::spawn(move || exec::job(rx, cmd, out_perm, show_filesystem_errors));149 150 // Push the handle of the spawned thread into the vector for later joining.151 handles.push(handle);152 }41 unmodified lines194 }195 }196 }197 WorkerResult::Error(err) => {198+ if show_filesystem_errors {196- print_error!("{}", err);199+ print_error!("{}", err);200+ }201 }202 }203 }204 148 unmodified lines