Skip to content

Commit

Permalink
find_nix_files: filter out broken symlinks and directories
Browse files Browse the repository at this point in the history
  • Loading branch information
Artturin committed Oct 9, 2023
1 parent 727672e commit f56d5c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ pub fn find_nix_files(path: &PathBuf) -> Vec<String> {
.filter_entry(|e| !is_hidden(e))
.filter_map(|entry| entry.ok())
.filter(is_nix_file)
// pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo.nix
// is a broken symlink.
.filter(|path| path.metadata().is_ok())
// 'pkgs/test/nixpkgs-check-by-name/tests/package-nix-dir/pkgs/by-name/fo/foo/package.nix'
// is a directory.
.filter(|path| (!path.metadata().unwrap().is_dir()))
.map(|f| f.path().to_str().unwrap().to_owned())
.collect()
}
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ fn main() -> ExitCode {
}

match_vec.par_extend(entries.into_par_iter().progress_with(pb).flat_map(|entry| {
// println!("{:?}", entry);
find_lints(
&entry,
read_to_string(&entry).unwrap().trim(),
Expand Down

0 comments on commit f56d5c4

Please sign in to comment.