[yabridgectl] Canonicalize when checking blacklist

As mentioned in #156.
This commit is contained in:
Robbert van der Helm
2022-01-07 18:59:51 +01:00
parent dabefef098
commit 263b192daa
2 changed files with 11 additions and 1 deletions
+9 -1
View File
@@ -348,7 +348,15 @@ pub fn index(directory: &Path, blacklist: &HashSet<&Path>) -> SearchIndex {
for (file_idx, entry) in WalkDir::new(directory)
.follow_links(true)
.into_iter()
.filter_entry(|e| !blacklist.contains(e.path()))
.filter_entry(|e| {
// The blacklist entries are canonicalized to resolve symlinks and to normalize slashes,
// so we should do the same thing here as well
if let Ok(p) = e.path().canonicalize() {
!blacklist.contains(p.as_path())
} else {
true
}
})
.filter_map(|e| e.ok())
.filter(|e| !e.file_type().is_dir())
.enumerate()