Revert back to master state
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by sharkdp · committed by David Peter · parent 918dfc6 · Browse files · 1 file·+3 added−35 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+3 added−35 removed
- other:+3 added−35 removed
Provenance
- Commit
bfc8c42- Tree
077c34f- Author
sharkdp <davidpeter@web.de>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
918dfc6
1 file changed+3 added−35 removed
modified:src/walk.rs+3 added-35 removed
11 unmodified lines12 use crate::internal::{opts::FdOptions, osstr_to_bytes, MAX_BUFFER_LENGTH};13 use crate::output;14 15 use std::borrow::Cow;16-use std::convert::TryFrom;16 use std::error::Error;17 use std::ffi::OsStr;19-use std::fs;18 use std::io;19 use std::path::PathBuf;20 use std::process;21 use std::sync::atomic::{AtomicBool, Ordering};21 unmodified lines43 Entry(PathBuf),44 Error(ignore::Error),45 }46 49-/// Converts a WorkerResult to a PathBuf. This is required as in some cases,50-/// the underlying `ignore` libary will return an error when we actually51-/// still want to show the path.52-///53-/// Currently, the cases supported are:54-/// - a broken symlink should still be found and the path returned55-impl TryFrom<WorkerResult> for PathBuf {56- type Error = ignore::Error;57-58- fn try_from(worker_result: WorkerResult) -> Result<PathBuf, Self::Error> {59- match worker_result {60- WorkerResult::Entry(value) => return Ok(value),61- WorkerResult::Error(ignore_error) => {62- if let ignore::Error::WithPath { path, err } = &ignore_error {63- if let ignore::Error::Io(ref io_err) = **err {64- if io_err.kind() == io::ErrorKind::NotFound65- && fs::symlink_metadata(&path)66- .map_or(false, |m| m.file_type().is_symlink())67- {68- // Broken symlink69- return Ok(path.to_path_buf());70- }71- }72- }73- return Err(ignore_error);74- }75- }76- }77-}78-47 /// Recursively scan the given search path for files / pathnames matching the pattern.48 ///49 /// If the `--exec` argument was supplied, this will create a thread pool for executing50 /// jobs in parallel from a given command line and the discovered paths. Otherwise, each149 unmodified lines200 let stdout = io::stdout();201 let mut stdout = stdout.lock();202 203 for worker_result in rx {236- match PathBuf::try_from(worker_result) {237- Ok(value) => {204+ match worker_result {205+ WorkerResult::Entry(value) => {206 match mode {207 ReceiverMode::Buffering => {208 buffer.push(value);209 20 unmodified lines230 output::print_entry(&mut stdout, &value, &config, &wants_to_quit);231 }232 }233 }266- Err(err) => {234+ WorkerResult::Error(err) => {235 if show_filesystem_errors {236 print_error!("{}", err);237 }238 }150 unmodified lines