From d1bc82a3531b6a63599e067431ed33b00b445719 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 3 Aug 2021 17:59:35 +0200 Subject: [PATCH] engine: skip over symlinks (#123) We don't want to format files outside the directory, and if the symlink destination is in the repo, it'll be matched when iterating over it. Fixes #122. --- src/engine.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine.rs b/src/engine.rs index 8036f7b0..f279e0df 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -132,7 +132,10 @@ pub fn run_treefmt( match walk_entry { Ok(dir_entry) => { if let Some(file_type) = dir_entry.file_type() { - if !file_type.is_dir() { + // Ignore folders and symlinks. We don't want to format files outside the + // directory, and if the symlink destination is in the repo, it'll be matched + // when iterating over it. + if !file_type.is_dir() && !file_type.is_symlink() { // Keep track of how many files were traversed traversed_files += 1;