Skip to content

Commit

Permalink
subber: sync file to disk
Browse files Browse the repository at this point in the history
  • Loading branch information
martinlindhe committed Oct 12, 2024
1 parent d6a0bd8 commit 57420d0
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion cmd/subber/subber.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,22 @@ func writeText(outFileName string, skipBackups bool, text string) error {
return err
}
}
return os.WriteFile(outFileName, []byte(text), 0644)

f, err := os.Create(outFileName)
if err != nil {
return err
}
defer f.Close()

_, err = f.WriteString(text)
if err != nil {
return err
}
err = f.Sync()
if err != nil {
return err
}
return f.Close()
}

func fileExists(name string) bool {
Expand Down

0 comments on commit 57420d0

Please sign in to comment.