From cd51f090c396c52e361d2281c43b702b77da9b59 Mon Sep 17 00:00:00 2001 From: Giovanni Mirarchi Date: Fri, 12 Jul 2024 14:50:39 +0200 Subject: [PATCH 1/3] Fix when multiple include_filters --- src/lib.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 097fab2..ad52e7a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -275,12 +275,19 @@ impl CopyBuilder { } } + let mut include_filter_found = false; + for f in &self.include_filters { - if !entry.path().to_string_lossy().contains(f) { - continue 'files; + if entry.path().to_string_lossy().contains(f) { + include_filter_found = true; + break; } } + if !include_filter_found { + continue 'files; + } + // File is not present: copy it in any case let dest_exists = dest_entry.symlink_metadata().is_ok(); From cff230104757bdb0819d3b399ce6bf8c58bc412e Mon Sep 17 00:00:00 2001 From: Giovanni Mirarchi Date: Mon, 22 Jul 2024 11:49:41 +0200 Subject: [PATCH 2/3] Fix when no include_filters --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index ad52e7a..a919bf8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -284,7 +284,7 @@ impl CopyBuilder { } } - if !include_filter_found { + if !include_filter_found && !self.include_filters.is_empty() { continue 'files; } From e309613b0adf8ab2aea294f0943a9d258cac91b6 Mon Sep 17 00:00:00 2001 From: Giovanni Mirarchi Date: Mon, 22 Jul 2024 20:51:07 +0200 Subject: [PATCH 3/3] Code refactor --- src/lib.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a919bf8..e2d5d70 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -275,16 +275,11 @@ impl CopyBuilder { } } - let mut include_filter_found = false; - - for f in &self.include_filters { - if entry.path().to_string_lossy().contains(f) { - include_filter_found = true; - break; - } - } - - if !include_filter_found && !self.include_filters.is_empty() { + if !self + .include_filters + .iter() + .any(|f| entry.path().to_string_lossy().contains(f)) + { continue 'files; }