Skip to content

fix: rsync --files-from link_stat failures on non-NFC filenames - #4

Merged
ssalentin merged 2 commits into
mainfrom
sync-nfc-filename-fix
Oct 15, 2026
Merged

ssalentin merged 2 commits into
mainfrom
sync-nfc-filename-fix

Conversation

@ssalentin

Copy link
Copy Markdown
Owner

What a user gets

Before: Syncing to a device whose library contains filenames that aren't
NFC-normalized (e.g. German audiobook chapter titles with ü/ä/ö/ß, stored
NFD-decomposed) fails for every such file:

rsync: [sender] link_stat "<path>" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23)
rsync failed (exit 23)

Reported against the Mlove player syncing the hoerspiele library (Harry
Potter audiobook), but the bug affects any rsync-firmware device (sony,
rockbox, mlove) whenever a source filename isn't already NFC.

After: Files transfer regardless of Unicode normalization form. The
NFC-aware diff still treats NFC/NFD forms of the same name as equal (so it
doesn't re-copy every run), but rsync is now given the real on-disk path for
the actual transfer.

Root cause

scan_music_dir (src/engine.rs) keyed its map by the NFC-normalized
relative path and discarded the real on-disk path. run_rsync_device then
handed that normalized key straight to rsync's --files-from, which does a
literal link_stat against the filesystem — a mismatch between the
normalized key and the real (e.g. NFD) on-disk bytes makes the stat fail.
remove_stale already avoided this (it resolves real paths from a fresh
scan); this fix applies the same pattern to the copy side.

How it was verified

  • Lead (orch-lead): read the bug report, traced the root cause in
    src/engine.rs, and reproduced the exact link_stat/exit-23 failure with
    a minimal rsync repro (NFD-named file + NFC-normalized --files-from
    entry) before scoping the fix.
  • Builder (commit 295213e): implemented the fix — scan_music_dir now
    returns (real_path, size, mtime) keyed by the NFC comparison key;
    to_copy sorts by that key (preserving FAT order) but emits the real
    path. Added two tests: one on scan_music_dir's map value, one that
    shells out to real rsync and reproduces the failure with the old key /
    success with the real path. cargo test: 36 passed, 1 pre-existing
    ignored. cargo build --release + cargo install --path . --force,
    installed-binary hash matched target/release.
  • Reviewer (dev-review): traced both call sites, confirmed remove_stale/
    to_delete untouched and still correct, independently ran cargo test
    (36 passed) and cargo clippy --all-targets (2 new cosmetic warnings in
    the new tests, non-blocking). No blocking findings.
  • QA (dev-qa): independent worktree build — cargo build, cargo test
    (36/36, including both new tests), cargo build --release. Confirmed no
    orphaned callers of scan_music_dir. Pass.
  • Builder (commit 11d63b3): addressed the reviewer's non-blocking clippy
    nit (std::slice::from_ref instead of cloning into a 1-element slice) in
    the two new tests — test-only, no behavior change.

Not run: no physical device or the user's real hoerspiele library on
this host (not present) — the real-rsync-against-a-temp-NFD-file
integration test is the closest available substitute, and it exercises the
exact --files-from code path that failed in the report.

What depends on this

This is the device-sync "diff → copy" step used by every rsync-firmware
device (sony, rockbox, mlove) — the fix benefits all of them, not only the
Mlove player in the original report. No UI changes.

Unsure

Nothing outstanding. The fix doesn't depend on knowing the exact non-NFC
form involved (NFD assumed, matching the reproduction) — "use the real path,
not the normalized one" holds regardless.

🤖 Generated with Claude Code

ssalentin and others added 2 commits October 15, 2026 15:30
scan_music_dir keyed its map by the NFC-normalized relative path and
discarded the real on-disk path. run_rsync_device then handed that
normalized key straight to rsync's --files-from, which does a literal
link_stat against the filesystem — if the file is actually stored NFD
(or any other non-NFC form), the stat misses and rsync fails every such
file with link_stat ... No such file or directory (2) / exit 23.

scan_music_dir now keeps the real on-disk relative path alongside
(size, mtime), keyed by the same NFC comparison key so src/dst entries
that differ only in normalization form still compare equal. to_copy is
built and FAT-order-sorted by that key but emits the real path, which
is what gets written to rsync's file list. remove_stale already did
this correctly by resolving real paths from a fresh directory scan.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Addresses a non-blocking clippy::cloned_ref_to_slice_refs nit from review
on 295213e.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ssalentin
ssalentin merged commit 5d7fa8b into main Oct 15, 2026
1 check passed
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