mirror of
https://github.com/sharkdp/fd.git
synced 2024-09-28 13:01:30 +02:00
Revert back to master state
This commit is contained in:
parent
918dfc6ef0
commit
bfc8c42444
38
src/walk.rs
38
src/walk.rs
@ -13,10 +13,8 @@ use crate::internal::{opts::FdOptions, osstr_to_bytes, MAX_BUFFER_LENGTH};
|
|||||||
use crate::output;
|
use crate::output;
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::convert::TryFrom;
|
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::fs;
|
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process;
|
use std::process;
|
||||||
@ -46,36 +44,6 @@ pub enum WorkerResult {
|
|||||||
Error(ignore::Error),
|
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.
|
/// 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
|
/// 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();
|
let mut stdout = stdout.lock();
|
||||||
|
|
||||||
for worker_result in rx {
|
for worker_result in rx {
|
||||||
match PathBuf::try_from(worker_result) {
|
match worker_result {
|
||||||
Ok(value) => {
|
WorkerResult::Entry(value) => {
|
||||||
match mode {
|
match mode {
|
||||||
ReceiverMode::Buffering => {
|
ReceiverMode::Buffering => {
|
||||||
buffer.push(value);
|
buffer.push(value);
|
||||||
@ -263,7 +231,7 @@ fn spawn_receiver(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
WorkerResult::Error(err) => {
|
||||||
if show_filesystem_errors {
|
if show_filesystem_errors {
|
||||||
print_error!("{}", err);
|
print_error!("{}", err);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user