Skip to content

Commit fa514a5

Browse files
committed
Merge remote-tracking branch 'origin/dbperm'
2 parents 22eca07 + f4594bf commit fa514a5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

gohash_db/database.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,17 @@ const (
2929

3030
// WriteDatabase writes the encrypted database to the given filePath with the provided state and key.
3131
func WriteDatabase(filePath, password string, data *State) error {
32-
file, err := os.Create(filePath)
32+
file, err := os.OpenFile(filePath, os.O_RDWR|os.O_CREATE, 0600)
3333
if err != nil {
3434
return err
3535
}
3636
defer file.Close()
3737

38+
err = file.Truncate(0)
39+
if err != nil {
40+
return err
41+
}
42+
3843
stateBytes, err := data.bytes()
3944
if err != nil {
4045
return err

0 commit comments

Comments
 (0)