Skip to content

fix: File content modification made a bit more safe and sane

Kerri Miller requested to merge github/fork/andhe/renameio into trunk

Created by: andhe

Description Atomically replace file that was previously truncated and then modified content written out again (without any error handling). New code also does some basic error handling. Replacing the old code with using renameio.WriteFile instead also got rid of the missing/implicit file Close(). See commit message for futher details!

While at it also fix up the ReadAndAppend method usage and implementation that is used to extent .gitignore so that it behaves better with regard to newline handling.

Testing Some trivial manual testing has been done to try to verify the code works as expected, but could certainly be better and more extensively.

Merge request reports