Skip to content

refactor: scan a single input directory#78

Merged
lwshang merged 1 commit into
mainfrom
refactor/scan-single-dir
Jun 5, 2026
Merged

refactor: scan a single input directory#78
lwshang merged 1 commit into
mainfrom
refactor/scan-single-dir

Conversation

@lwshang
Copy link
Copy Markdown
Collaborator

@lwshang lwshang commented Jun 5, 2026

What

scan() now takes a single dir: &str instead of dirs: &[String].

The sync plugin already enforces exactly one input directory (the [d] => d match in sync()), so scan() never had more than one tree to walk. This drops the now-pointless multi-dir machinery:

  • Removed the for dir in dirs loop.
  • Removed the seen_keys HashSet and its duplicate-key error path. Within a single tree walk, distinct filesystem paths always yield distinct keys, so the cross-dir collision check was unreachable.
  • walk() loses its seen_keys parameter.
  • sync() passes the validated single dir to scan() and logs from {dir} instead of the {:?} slice debug.

Tests

Removed the two tests that only existed to exercise multi-dir merging (duplicate_key_across_two_source_dirs, multiple_source_dirs). Remaining scan tests updated to the single-dir signature. cargo test -p sync-core — 188 passed.

🤖 Generated with Claude Code

The sync plugin enforces exactly one input directory, so `scan()` no
longer needs to merge multiple trees. Take a single `dir: &str` instead
of `dirs: &[String]`, and drop the `seen_keys` cross-dir duplicate-key
guard — within one tree walk, distinct paths always yield distinct keys,
so that check was unreachable.

Removes the two tests that only exercised multi-dir merging.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lwshang lwshang marked this pull request as ready for review June 5, 2026 17:46
@lwshang lwshang requested a review from a team as a code owner June 5, 2026 17:46
@lwshang lwshang merged commit 47a7ff2 into main Jun 5, 2026
6 checks passed
@lwshang lwshang deleted the refactor/scan-single-dir branch June 5, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant