Batch track removal that guarantees the database matches the disk #15
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
wokoman/ironpod!15
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/batch-removal"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A single batch-removal entry point that owns the rule every caller currently re-implements: the database on disk always matches the audio files on disk.
Nothing changes for users yet. The single-track removal stays public and every caller stays on it, so the tree stays green; the migration is #5.
Built to the interface settled in #4, with one deviation, which needs a look before this merges.
failed_idisOption<u32>, notu32. The pinned shape has no honest value for it when what fails is the database write that follows the removals — every removal succeeded, so no track's id is the answer, and picking the last one would name a track that is fine.Nonemeans "the write failed", which is a state a caller may well want to tell apart: the tracks are gone from disk, and the database on disk still lists them. Reversible either way, but it is a change to a shape the ticket asked to pin precisely, so say if you would rather have something else there.Everything else is as specified. Stop at the first failed removal, deliberately unlike the copy direction — a failed copy is per-file, a failed delete is usually systemic and pressing on turns one stranded file into two hundred. That divergence is now documented on both sides, since on one side alone it reads like an accident. Write only when at least one removal succeeded, with the reasoning in a comment so it does not get deleted as dead weight. The callback fires before each removal, because the caller with a screen is single-threaded and has to repaint before it blocks.
RemoveFailedgets a hand-writtenDisplay/Error, asanyhow::Errorcannot be a derived source. Rustdoc has the# Errorssection covering the stopping rule, the write guarantee, and that a write renumbers track IDs so held ids are meaningless afterwards.Three tests, all with no device attached, one per acceptance criterion:
(0,2)then(1,2)— before each removal, not after.Forcing the failure needs no permissions or root: putting a non-empty directory where the audio file was makes unlink refuse, on macOS and on Linux alike. The middle test also has to re-read every id after its setup write, which is the ID-renumbering rule the rustdoc warns about, demonstrated.
64 unit tests pass,
cargo clippy --all-targetsclean.Refs #4.