Fix include filter: also include directory contents

When TARGET_INCLUDE has a directory pattern like 'embajada/', rsync
would include the directory but exclude its contents (files didn't
match any include rule before hitting --exclude=*). Now adds a
'pattern**' include for each directory pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shuki
2026-03-06 19:01:14 +02:00
parent 28d85ed89f
commit 276b49ea0a

View File

@@ -188,7 +188,12 @@ transfer_folder() {
for pat in "${inc_patterns[@]}"; do for pat in "${inc_patterns[@]}"; do
pat="${pat#"${pat%%[![:space:]]*}"}" pat="${pat#"${pat%%[![:space:]]*}"}"
pat="${pat%"${pat##*[![:space:]]}"}" pat="${pat%"${pat##*[![:space:]]}"}"
[[ -n "$pat" ]] && filter_opts+=(--include="$pat") [[ -z "$pat" ]] && continue
filter_opts+=(--include="$pat")
# For directory patterns, also include their contents
if [[ "$pat" == */ ]]; then
filter_opts+=(--include="${pat}**")
fi
done done
filter_opts+=(--exclude="*") filter_opts+=(--exclude="*")
# Prune empty dirs left by directory traversal # Prune empty dirs left by directory traversal