Skip to content
Myr

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

1 file+3 added−35 removed

modified:src/walk.rs+3 added-35 removed
11 unmodified lines
12use crate::internal::{opts::FdOptions, osstr_to_bytes, MAX_BUFFER_LENGTH};13use crate::output;1415use std::borrow::Cow;16use std::convert::TryFrom;16use std::error::Error;17use std::ffi::OsStr;19use std::fs;18use std::io;19use std::path::PathBuf;20use std::process;21use std::sync::atomic::{AtomicBool, Ordering};
21 unmodified lines
43 Entry(PathBuf),44 Error(ignore::Error),45}4649/// 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 returned55impl TryFrom<WorkerResult> for PathBuf {56 type Error = ignore::Error;5758 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}7847/// 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, each
149 unmodified lines
200 let stdout = io::stdout();201 let mut stdout = stdout.lock();202203 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 lines
230 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