Repository navigation
tarfs: keep a package file's changes once it is opened to write - #2612
Merged
kevinmdavis merged 2 commits intoOct 28, 2026
Merged
Conversation
kevinmdavis
force-pushed
the
con-3671-tarfs-truncate
branch
from
October 27, 2026 23:45
368e830 to
a2abe68
Compare
shimmerjs
previously approved these changes
Oct 28, 2026
konradzapalowicz
previously approved these changes
Oct 28, 2026
codysoyland
reviewed
Oct 28, 2026
codysoyland
left a comment
Contributor
There was a problem hiding this comment.
Automated review by unblok using Codex · gpt-6-astra · medium reasoning effort
Agent recommended action: Request changes
Requesting changes: a failed writable open can permanently hide the package file's content.
Worth fixing
- Commit the written state only after buffering succeeds: pkg/tarfs/fs.go:429.
What I verified
- At a2abe68, a backing reader returning zero bytes and an error makes OpenFile(O_RDWR) fail, but the next ReadFile succeeds with empty content and Stat reports zero. The same reproduction against the base returns the original eight bytes.
- The written check at pkg/tarfs/fs.go:409 prevents recovery after that failure; Size uses the same state at pkg/tarfs/fs.go:999.
- TestTarFSTruncatePackageFile covers successful truncation and subsequent content/size, but not a failed backing read.
A package-backed file opened to be modified copies its content into memory, and tarfs took empty memory to mean the file was still the package's. A file truncated to empty through OpenFile then read back the package's content, at the package's size, so the truncation was lost. A node now records that it was opened to write, and from then on its content is what is in memory, even when that is nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kevinmdavis
dismissed stale reviews from konradzapalowicz and shimmerjs
via
October 28, 2026 17:25
e060645
kevinmdavis
force-pushed
the
con-3671-tarfs-truncate
branch
from
October 28, 2026 17:25
a2abe68 to
e060645
Compare
codysoyland
approved these changes
Oct 28, 2026
codysoyland
left a comment
Contributor
There was a problem hiding this comment.
Automated review by unblok using Codex · gpt-6-astra · medium reasoning effort
Re-reviewed after e060645. LGTM.
Addressed: failed backing read now leaves the node unchanged; pkg/tarfs/fs.go:427-434 commits data and written only after success.
What I verified
- The error return at pkg/tarfs/fs.go:428 precedes both node mutations, including when ReadAll returns partial data.
- Ran TestTarFSPackageFileReadFailure at e060645: passed. It checks preserved content and size, a successful writable retry, and unchanged backing content.
- Re-ran my original zero-byte read-error reproduction at e060645: subsequent ReadFile returns the original eight bytes and Stat reports size eight.
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.
A package-backed file opened to be modified copies its content into memory, and tarfs took empty memory to mean the file was still the package's. A file truncated to empty through OpenFile then read back the package's content, at the package's size, so the truncation was lost.
A node now records that it was opened to write, and from then on its content is what is in memory, even when that is nothing.