Revert back to master state

This commit is contained in:
sharkdp 2020-02-28 17:46:49 +01:00 committed by David Peter
parent 918dfc6ef0
commit bfc8c42444
1 changed files with 3 additions and 35 deletions

View File

@ -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<WorkerResult> for PathBuf {
type Error = ignore::Error;
fn try_from(worker_result: WorkerResult) -> Result<PathBuf, Self::Error> {
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);
}