Repository navigation
fix: fail closed on unsafe sync operations - #5
Merged
Merged
Conversation
A read_dir or metadata failure during scan_music_dir silently shrank the source map, so run_rsync_device could delete valid device files that were merely missing from the incomplete scan. Scans now return an error, which aborts before any stale deletion; an empty directory still scans as successfully empty. Stale deletion now uses the real on-disk paths from the device scan and fails the sync when a removal fails instead of logging a success that can be larger than the number of files actually removed. finalize_fat now asks findmnt whether the resolved block device still has any mount target before running fatsort, and refuses with a manual-action error when it does.
findmnt exits 1 both when a source has no mount target and when the query itself fails, so the previous check could not tell them apart and would let fatsort run on a device whose mount state was unknown. Read the whole SOURCE,TARGET table instead: a successful read with no entry for the device is positive proof it is unmounted, while a failed read now refuses with a manual-action error. Add regression coverage for the failed-query distinction.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardens the device-sync pipeline so destructive operations fail closed.
fatsort. Unknown mount state refuses with a manual-action error.Verification
cargo test: 42 passed, 0 failed, 1 intentionally ignored.dbfdab1.git diff --check: clean.Scoped gap: no physical FAT media was available for a real
fatsortinvocation. Rustfmt and Clippy still report pre-existing debt elsewhere in the checkout; this change adds no new findings.