Skip to content

feat: wire per-directory merge filters into transfer layer - #3034

Merged
oferchen merged 1 commit into
masterfrom
feature/wire-merge-filters
Mar 28, 2026
Merged

oferchen merged 1 commit into
masterfrom
feature/wire-merge-filters

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Replaces flat Option<FilterSet> in GeneratorContext with FilterChain for per-directory scoped filter rules
  • Generator walk_path() now calls enter_directory()/leave_directory() on the filter chain during recursive directory traversal, reading .rsync-filter merge files per upstream push_local_filters()/pop_local_filters() pattern
  • DirMerge rules from the wire protocol are extracted into DirMergeConfig entries instead of being silently skipped
  • Receiver's delete_extraneous_files() evaluates FilterChain::allows_deletion() before removing destination files, respecting protect/risk rules
  • Receiver's setup_transfer() builds a FilterChain from received wire filter rules for deletion filtering

Test plan

  • Generator skips files matching per-directory merge rules
  • Nested directories with cascading merge rules (inherited exclusions)
  • Filters are properly scoped (rules from dir A don't affect dir B)
  • Merge file exclude_self option works
  • No merge configs preserves unchanged behavior
  • DirMerge wire rules are parsed into DirMergeConfig with correct modifiers
  • No-inherit DirMerge modifier is preserved
  • Receiver protect rules prevent deletion
  • Empty filter chain allows all deletions
  • Filter chain get/set accessors work
  • All 1266 existing transfer tests pass
  • Clean clippy and fmt across full workspace

Replace the flat `Option<FilterSet>` in GeneratorContext with a
`FilterChain` that supports per-directory scoped rules. During
`walk_path()`, the generator now calls `enter_directory()` /
`leave_directory()` to read `.rsync-filter` files and push/pop
scoped rules as directories are entered and left, matching upstream
rsync's `push_local_filters()` / `pop_local_filters()` pattern.

Wire `FilterChain` into the receiver for deletion protection:
`delete_extraneous_files()` now evaluates `allows_deletion()` before
removing destination files, respecting protect/risk rules.

DirMerge rules from the wire protocol are no longer silently skipped -
they are extracted into `DirMergeConfig` entries and registered on
the `FilterChain` for per-directory merge file scanning.

Key changes:
- GeneratorContext.filters -> filter_chain (FilterChain)
- parse_received_filters returns (FilterSet, Vec<DirMergeConfig>)
- walk_path enters/leaves directories on the filter chain
- ReceiverContext gains filter_chain for deletion filtering
- setup_transfer builds FilterChain from received wire rules
- wire_rule_to_dir_merge_config maps wire modifiers to DirMergeConfig
@github-actions github-actions Bot added the enhancement New feature or request label Mar 28, 2026
@oferchen
oferchen merged commit 819c2ef into master Mar 28, 2026
36 checks passed
@oferchen
oferchen deleted the feature/wire-merge-filters branch March 28, 2026 16:57
oferchen added a commit that referenced this pull request May 1, 2026
Replace the flat `Option<FilterSet>` in GeneratorContext with a
`FilterChain` that supports per-directory scoped rules. During
`walk_path()`, the generator now calls `enter_directory()` /
`leave_directory()` to read `.rsync-filter` files and push/pop
scoped rules as directories are entered and left, matching upstream
rsync's `push_local_filters()` / `pop_local_filters()` pattern.

Wire `FilterChain` into the receiver for deletion protection:
`delete_extraneous_files()` now evaluates `allows_deletion()` before
removing destination files, respecting protect/risk rules.

DirMerge rules from the wire protocol are no longer silently skipped -
they are extracted into `DirMergeConfig` entries and registered on
the `FilterChain` for per-directory merge file scanning.

Key changes:
- GeneratorContext.filters -> filter_chain (FilterChain)
- parse_received_filters returns (FilterSet, Vec<DirMergeConfig>)
- walk_path enters/leaves directories on the filter chain
- ReceiverContext gains filter_chain for deletion filtering
- setup_transfer builds FilterChain from received wire rules
- wire_rule_to_dir_merge_config maps wire modifiers to DirMergeConfig
oferchen added a commit that referenced this pull request May 5, 2026
Replace the flat `Option<FilterSet>` in GeneratorContext with a
`FilterChain` that supports per-directory scoped rules. During
`walk_path()`, the generator now calls `enter_directory()` /
`leave_directory()` to read `.rsync-filter` files and push/pop
scoped rules as directories are entered and left, matching upstream
rsync's `push_local_filters()` / `pop_local_filters()` pattern.

Wire `FilterChain` into the receiver for deletion protection:
`delete_extraneous_files()` now evaluates `allows_deletion()` before
removing destination files, respecting protect/risk rules.

DirMerge rules from the wire protocol are no longer silently skipped -
they are extracted into `DirMergeConfig` entries and registered on
the `FilterChain` for per-directory merge file scanning.

Key changes:
- GeneratorContext.filters -> filter_chain (FilterChain)
- parse_received_filters returns (FilterSet, Vec<DirMergeConfig>)
- walk_path enters/leaves directories on the filter chain
- ReceiverContext gains filter_chain for deletion filtering
- setup_transfer builds FilterChain from received wire rules
- wire_rule_to_dir_merge_config maps wire modifiers to DirMergeConfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant