Repository navigation
fix(cli): a commit that cannot read a file lands no version - #10
Merged
adammharris merged 1 commit intoNov 6, 2026
Merged
Conversation
mocfl commit read the tree through map_while and handed the iterator to Object::commit, which takes what it is given as the version's complete state. A file it could not read ended the iterator early, so the version landed with every path from that file on deleted, and only then did the command report the failure. Run again it added another version, an unreadable first file got past the --allow-empty guard, and a first commit wrote a partial object. Object::try_commit takes an iterator of Results and abandons the version at the first Err, during staging, before anything is written. commit is try_commit over an iterator that cannot fail, and the CLI uses try_commit, reading one file at a time as before. Behavioural-change: mocfl commit that cannot read a file now writes nothing, where it used to land a partial version (or a partial first object) before exiting non-zero.
adammharris
deleted the
agent/backlog-an-unreadable-file-commits-a-partial-version
branch
November 6, 2026 19:47
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.
What changed
Object::try_commitis new. It takes an iterator ofResults and abandons the version at the firstErr, during staging, before anything is written.Object::commitis nowtry_commitover an iterator that cannot fail. Its signature and behaviour are unchanged.mocfl commitcallstry_commit, so a file it cannot read stops the commit. The error message and exit code are the same as before.Why
mocfl commitread the tree throughmap_while, so an unreadable file ended the iterator early.Object::committakes what it is given as the version's complete state, so the version landed with every path from that file onward deleted, and the failure was reported only afterwards. Running it again added another version, an unreadable first file got past the--allow-emptyguard, and a first commit wrote a partial object.Memory use is unchanged: files are still read one at a time, through the same staging loop.
Task
Closes
docs/tasks/an-unreadable-file-commits-a-partial-version.md.Verification
mocfl-cli/tests/commit_unreadable.rsdrives the real binary and compares the object's bytes: an object with a version (including a second failed run), a first commit, an unreadable file that sorts first, and a commit that succeeds once the file is readable. All 4 failed before the fix and pass after it.mocfl/src/object.rscovertry_commit, including that nothing after theErris asked for.lsstill lists all four files, the object stays at v1 after two failed runs,validate --deeppasses, and no object appears for a failed first commit.cargo fmt --all --check,cargo clippy --all-targets -- -D warnings,cargo test --all-targetswithOCFL_FIXTURESset to a fresh clone of OCFL/fixtures,cargo test --doc, andcargo +1.88 check --all-targets.rocflvalidation step, becauserocflis not installed on this machine. The interop test that emits the object does pass; this PR's CI runs therocflstep.The new CLI tests return early if the user can read a mode-000 file (root), since they would prove nothing there. They are
cfg(unix).