Skip to content

Commit f610647

Browse files
committed
Fix ignoral of non-existent paths
1 parent 888deeb commit f610647

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
- `--config-file` no longer erroneously accepts a path to a directory and searches from it for a
2828
`pasfmt.toml` file. It is now an error to provide a path to a directory.
2929
- Detection of decoding errors when reading from stdin.
30+
- Silent ignoral of non-existent paths (were being treated as globs matching no files).
3031

3132
## [0.3.0] - 2024-05-29
3233

orchestrator/src/file_formatter.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl FileFormatter {
4040
warn!("'{}' is not a valid file path/glob", path);
4141
}
4242

43-
fn get_valid_files<S: AsRef<str>>(&self, paths: &[S]) -> Vec<PathBuf> {
43+
fn find_files<S: AsRef<str>>(&self, paths: &[S]) -> Vec<PathBuf> {
4444
let mut valid_paths = vec![];
4545
paths.iter().map(AsRef::as_ref).for_each(|path_str| {
4646
let path = Path::new(path_str);
@@ -55,16 +55,16 @@ impl FileFormatter {
5555
}
5656
}));
5757
}
58-
Ok(metadata) if metadata.is_file() => {
59-
valid_paths.push(path.to_path_buf());
60-
}
61-
_ => match glob(path_str) {
58+
_ if path_str.contains('*') => match glob(path_str) {
6259
Err(_) => self.warn_invalid_glob(path_str),
6360
Ok(glob) => glob.for_each(|entry| match entry {
6461
Err(_) => self.warn_invalid_file(path_str),
6562
Ok(path) => valid_paths.push(path),
6663
}),
6764
},
65+
_ => {
66+
valid_paths.push(path.to_path_buf());
67+
}
6868
}
6969
});
7070

@@ -116,9 +116,7 @@ impl FileFormatter {
116116
{
117117
open_options.read(true);
118118

119-
let valid_paths: Vec<_> = self.get_valid_files(paths);
120-
121-
valid_paths
119+
self.find_files(paths)
122120
.into_par_iter()
123121
.map_init(
124122
|| (Vec::<u8>::new(), String::new()),

0 commit comments

Comments
 (0)