From bfc8c42444725793ebb313b3003a090a619028fb Mon Sep 17 00:00:00 2001 From: sharkdp Date: Fri, 28 Feb 2020 17:46:49 +0100 Subject: [PATCH] Revert back to master state --- src/walk.rs | 38 +++----------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) diff --git a/src/walk.rs b/src/walk.rs index ab5d449..b3190e0 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -13,10 +13,8 @@ use crate::internal::{opts::FdOptions, osstr_to_bytes, MAX_BUFFER_LENGTH}; use crate::output; use std::borrow::Cow; -use std::convert::TryFrom; use std::error::Error; use std::ffi::OsStr; -use std::fs; use std::io; use std::path::PathBuf; use std::process; @@ -46,36 +44,6 @@ pub enum WorkerResult { Error(ignore::Error), } -/// Converts a WorkerResult to a PathBuf. This is required as in some cases, -/// the underlying `ignore` libary will return an error when we actually -/// still want to show the path. -/// -/// Currently, the cases supported are: -/// - a broken symlink should still be found and the path returned -impl TryFrom for PathBuf { - type Error = ignore::Error; - - fn try_from(worker_result: WorkerResult) -> Result { - match worker_result { - WorkerResult::Entry(value) => return Ok(value), - WorkerResult::Error(ignore_error) => { - if let ignore::Error::WithPath { path, err } = &ignore_error { - if let ignore::Error::Io(ref io_err) = **err { - if io_err.kind() == io::ErrorKind::NotFound - && fs::symlink_metadata(&path) - .map_or(false, |m| m.file_type().is_symlink()) - { - // Broken symlink - return Ok(path.to_path_buf()); - } - } - } - return Err(ignore_error); - } - } - } -} - /// Recursively scan the given search path for files / pathnames matching the pattern. /// /// If the `--exec` argument was supplied, this will create a thread pool for executing @@ -233,8 +201,8 @@ fn spawn_receiver( let mut stdout = stdout.lock(); for worker_result in rx { - match PathBuf::try_from(worker_result) { - Ok(value) => { + match worker_result { + WorkerResult::Entry(value) => { match mode { ReceiverMode::Buffering => { buffer.push(value); @@ -263,7 +231,7 @@ fn spawn_receiver( } } } - Err(err) => { + WorkerResult::Error(err) => { if show_filesystem_errors { print_error!("{}", err); }