Skip to content

fix(writer): truncate existing files when writing - #1640

Merged
LinkinStars merged 2 commits into
apache:devfrom
seiyab:openfile-flag
Oct 14, 2026
Merged

LinkinStars merged 2 commits into
apache:devfrom
seiyab:openfile-flag

Conversation

@seiyab

@seiyab seiyab commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

writer.WriteFile leaves trailing bytes when overwriting an existing file with shorter content. Add O_TRUNC so the file contains exactly the new content.
Adds a regression test that fails before the fix and passes afterward. Verified with go test ./pkg/writer.


Context
I found this scanning this project with an static code analyzer while I evaluate the analyzer.
I might submit a few other minor fixes one by one if this is accepted.

seiyab and others added 2 commits October 2, 2026 00:08
Co-Authored-By: codex <codex@openai.com>
Co-Authored-By: codex <codex@openai.com>
@LinkinStars LinkinStars self-assigned this Oct 14, 2026
@LinkinStars LinkinStars added this to the v2.0.4 milestone Oct 14, 2026
@LinkinStars
LinkinStars changed the base branch from main to dev October 14, 2026 09:41
@LinkinStars
LinkinStars merged commit 35ffe7a into apache:dev Oct 14, 2026
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.

2 participants