Skip to content

Commit

Permalink
Truncate index file when open file
Browse files Browse the repository at this point in the history
  • Loading branch information
nao1215 committed Nov 4, 2023
1 parent df194ee commit 671b48b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (i *Index) walk() error {
func (i *Index) write() (err error) {
if i.w == nil {
const readUserOnly = 0600
if i.w, err = os.OpenFile(filepath.Clean(filepath.Join(i.targetDir, "index.md")), os.O_WRONLY|os.O_CREATE, readUserOnly); err != nil {
if i.w, err = os.OpenFile(filepath.Clean(filepath.Join(i.targetDir, "index.md")), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, readUserOnly); err != nil {
return err
}
}
Expand Down

0 comments on commit 671b48b

Please sign in to comment.