Skip to content

Commit

Permalink
Make sure to always truncate the file when writing (#200)
Browse files Browse the repository at this point in the history
The append action fully rewrites the file, so we should open in truncate
mode in this case as well.

<!---
  Thanks for contributing to NanoLedger!  Make sure all GitHub actions
  (test, lint & build) will pass and fill out the template.

  If any changes to your PR are necessary, we will ask for them
  throughout the review process.
  --->
 
<!---
  Please include a summary of the change and which issue is
  fixed. Please also include relevant motivation and context. If your
  pull request includes visual changes (which will probably be the
  case for anything that isn't a pure logic fix), please include
  screenshots showing those changes.
  --->

Fixes #197.

<!---
  If you did any manual testing (please do so), describe here what you
  tested and how. Provide instructions so that your tests can be
  easily run again by a maintainer.
  --->
  • Loading branch information
chvp authored Oct 28, 2024
1 parent aeacc6a commit e542521
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class LedgerRepository
if (!matches(fileUri)) {
onMismatch()
} else {
context.contentResolver.openOutputStream(fileUri, "w")
context.contentResolver.openOutputStream(fileUri, "wt")
?.let { OutputStreamWriter(it) }
?.use {
fileContents.value!!.forEach { line ->
Expand Down

0 comments on commit e542521

Please sign in to comment.