Skip to content

Commit 157e745

Browse files
Copilottwistedfall
andcommitted
Fix symlink detection in files_with_predicate function
Co-authored-by: twistedfall <[email protected]>
1 parent ea48cc8 commit 157e745

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

build.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ fn files_with_predicate<'p>(
8585
Ok(dir
8686
.read_dir()?
8787
.flatten()
88-
.filter_map(|e| e.file_type().is_ok_and(|typ| typ.is_file()).then(|| e.path()))
88+
.filter_map(|e| {
89+
let path = e.path();
90+
// Use path.metadata() instead of e.file_type() to follow symlinks
91+
path.metadata().ok().filter(|m| m.is_file()).map(|_| path)
92+
})
8993
.filter(move |p| predicate(p)))
9094
}
9195

0 commit comments

Comments
 (0)