Skip to content

Commit

Permalink
ensure cookie file exists before closing it (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmoragrega authored Jun 6, 2023
1 parent 09b72c7 commit 00d7a36
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,12 @@ func NewChainClient(
}

// create file if not exist
cookie_file, err := os.OpenFile(defaultChainCookieName, os.O_RDONLY|os.O_CREATE, 0666)
cookieFile, err := os.OpenFile(defaultChainCookieName, os.O_RDONLY|os.O_CREATE, 0666)
if err != nil {
cc.logger.Errorln(err)
} else {
defer cookieFile.Close()
}
defer cookie_file.Close()

// attempt to load from disk
data, err := os.ReadFile(defaultChainCookieName)
Expand Down

0 comments on commit 00d7a36

Please sign in to comment.