Skip to content
Myr

job.rs

This file

Path

src/exec/job.rs

63 lines · 2.1 KiB · Rust

Last changed by

fix: Better sanitizingThayne McCombsbefore adoption24198d9

History of this file

Take it

The walk stopped after 200 commits: lines older than 86d6e2d point at it.

Merge pull request #1657 from sharkdp/dependabot/cargo/clap-4.5.23Tavian Barnesbefore adoption86d6e2d

line 1why, one step back
1use crate::config::Config;

Merge pull request #1813 from tmccombs/rust-versionThayne McCombsbefore adoptiond23ac06

line 2why, one step back
2use crate::exit_codes::{ExitCode, merge_exitcodes};

Merge pull request #1657 from sharkdp/dependabot/cargo/clap-4.5.23Tavian Barnesbefore adoption86d6e2d

lines 3–25why, one step back
3use crate::walk::WorkerResult;
45use super::CommandSet;67/// An event loop that listens for inputs from the `rx` receiver. Each received input will8/// generate a command with the supplied command template. The generated command will then9/// be executed, and this process will continue until the receiver's sender has closed.10pub fn job(11 results: impl IntoIterator<Item = WorkerResult>,12 cmd: &CommandSet,13 config: &Config,14) -> ExitCode {15 // Output should be buffered when only running a single thread16 let buffer_output: bool = config.threads > 1;1718 let mut ret = ExitCode::Success;19 for result in results {20 // Obtain the next result from the receiver, else if the channel21 // has closed, exit from the loop22 let dir_entry = match result {23 WorkerResult::Entry(dir_entry) => dir_entry,24 WorkerResult::Error(err) => {25 if config.show_filesystem_errors {

fix: Better sanitizingThayne McCombsbefore adoption24198d9

line 26why, one step back
26 print_error!("{}", err);

Merge pull request #1657 from sharkdp/dependabot/cargo/clap-4.5.23Tavian Barnesbefore adoption86d6e2d

lines 27–35why, one step back
27 }
28 continue;29 }30 };3132 // Generate a command, execute it and store its exit code.33 let code = cmd.execute(34 dir_entry.stripped_path(config),35 config.path_separator.as_deref(),

Merge pull request #1805 from tmccombs/exec-nulsThayne McCombsbefore adoption5558e40

line 36why, one step back
36 config.null_separator,

Merge pull request #1657 from sharkdp/dependabot/cargo/clap-4.5.23Tavian Barnesbefore adoption86d6e2d

lines 37–55why, one step back
37 buffer_output,
38 );39 ret = merge_exitcodes([ret, code]);40 }41 // Returns error in case of any error.42 ret43}4445pub fn batch(46 results: impl IntoIterator<Item = WorkerResult>,47 cmd: &CommandSet,48 config: &Config,49) -> ExitCode {50 let paths = results51 .into_iter()52 .filter_map(|worker_result| match worker_result {53 WorkerResult::Entry(dir_entry) => Some(dir_entry.into_stripped_path(config)),54 WorkerResult::Error(err) => {55 if config.show_filesystem_errors {

fix: Better sanitizingThayne McCombsbefore adoption24198d9

line 56why, one step back
56 print_error!("{}", err);

Merge pull request #1657 from sharkdp/dependabot/cargo/clap-4.5.23Tavian Barnesbefore adoption86d6e2d

lines 57–63why, one step back
57 }
58 None59 }60 });6162 cmd.execute_batch(paths, config.batch_size, config.path_separator.as_deref())63}