mirror of
https://github.com/sharkdp/fd.git
synced 2024-09-28 13:01:30 +02:00
convert to path instead of cloning in batch exec
update changelog
This commit is contained in:
parent
3dc61b5f28
commit
22dbed0545
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
## Changes
|
## Changes
|
||||||
|
|
||||||
|
- Directories are now printed with an additional path separator at the end: `foo/bar/`
|
||||||
## Other
|
## Other
|
||||||
|
|
||||||
|
|
||||||
@ -49,7 +50,6 @@
|
|||||||
|
|
||||||
## Changes
|
## Changes
|
||||||
|
|
||||||
- Directories are now printed with an additional path separator at the end: `foo/bar/`
|
|
||||||
- Apply custom `--path-separator` to commands run with `--exec(-batch)` and `--list-details`, see #697 (@aswild)
|
- Apply custom `--path-separator` to commands run with `--exec(-batch)` and `--list-details`, see #697 (@aswild)
|
||||||
|
|
||||||
## Other
|
## Other
|
||||||
|
@ -37,6 +37,13 @@ impl DirEntry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn into_path(self) -> PathBuf {
|
||||||
|
match self.inner {
|
||||||
|
DirEntryInner::Normal(e) => e.into_path(),
|
||||||
|
DirEntryInner::BrokenSymlink(p) => p,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn file_type(&self) -> Option<FileType> {
|
pub fn file_type(&self) -> Option<FileType> {
|
||||||
match &self.inner {
|
match &self.inner {
|
||||||
DirEntryInner::Normal(e) => e.file_type(),
|
DirEntryInner::Normal(e) => e.file_type(),
|
||||||
|
@ -26,8 +26,8 @@ pub fn job(
|
|||||||
|
|
||||||
// Obtain the next result from the receiver, else if the channel
|
// Obtain the next result from the receiver, else if the channel
|
||||||
// has closed, exit from the loop
|
// has closed, exit from the loop
|
||||||
let value: DirEntry = match lock.recv() {
|
let dir_entry: DirEntry = match lock.recv() {
|
||||||
Ok(WorkerResult::Entry(val)) => val,
|
Ok(WorkerResult::Entry(dir_entry)) => dir_entry,
|
||||||
Ok(WorkerResult::Error(err)) => {
|
Ok(WorkerResult::Error(err)) => {
|
||||||
if show_filesystem_errors {
|
if show_filesystem_errors {
|
||||||
print_error(err.to_string());
|
print_error(err.to_string());
|
||||||
@ -40,7 +40,11 @@ pub fn job(
|
|||||||
// Drop the lock so that other threads can read from the receiver.
|
// Drop the lock so that other threads can read from the receiver.
|
||||||
drop(lock);
|
drop(lock);
|
||||||
// Generate a command, execute it and store its exit code.
|
// Generate a command, execute it and store its exit code.
|
||||||
results.push(cmd.generate_and_execute(value.path(), Arc::clone(&out_perm), buffer_output))
|
results.push(cmd.generate_and_execute(
|
||||||
|
dir_entry.path(),
|
||||||
|
Arc::clone(&out_perm),
|
||||||
|
buffer_output,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
// Returns error in case of any error.
|
// Returns error in case of any error.
|
||||||
merge_exitcodes(results)
|
merge_exitcodes(results)
|
||||||
@ -53,15 +57,17 @@ pub fn batch(
|
|||||||
buffer_output: bool,
|
buffer_output: bool,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
) -> ExitCode {
|
) -> ExitCode {
|
||||||
let paths = rx.iter().filter_map(|value| match value {
|
let paths = rx
|
||||||
WorkerResult::Entry(val) => Some(val.path().to_owned()),
|
.into_iter()
|
||||||
WorkerResult::Error(err) => {
|
.filter_map(|worker_result| match worker_result {
|
||||||
if show_filesystem_errors {
|
WorkerResult::Entry(dir_entry) => Some(dir_entry.into_path()),
|
||||||
print_error(err.to_string());
|
WorkerResult::Error(err) => {
|
||||||
|
if show_filesystem_errors {
|
||||||
|
print_error(err.to_string());
|
||||||
|
}
|
||||||
|
None
|
||||||
}
|
}
|
||||||
None
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
if limit == 0 {
|
if limit == 0 {
|
||||||
// no limit
|
// no limit
|
||||||
return cmd.generate_and_execute_batch(paths, buffer_output);
|
return cmd.generate_and_execute_batch(paths, buffer_output);
|
||||||
|
Loading…
Reference in New Issue
Block a user