From 263b192daa316f801fba87055555ebcb1c348c44 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Fri, 7 Jan 2022 18:59:51 +0100 Subject: [PATCH] [yabridgectl] Canonicalize when checking blacklist As mentioned in #156. --- CHANGELOG.md | 2 ++ tools/yabridgectl/src/files.rs | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b0bf5d3..b2bf0241 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). lead to a number of surprises. Yabridgectl will now print a warning upon syncing when using the symlink installation method, and the feature will be removed completely in yabridge 4.0. +- Blacklisted symlinks and files contained within symlinked directories are now + handled correctly when syncing. ### Packaging notes diff --git a/tools/yabridgectl/src/files.rs b/tools/yabridgectl/src/files.rs index 398e5e97..d81b1c10 100644 --- a/tools/yabridgectl/src/files.rs +++ b/tools/yabridgectl/src/files.rs @@ -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()