Skip to content

Commit

Permalink
Merge pull request #402 from oasisprotocol/pro-wh/bugfix/cleanup
Browse files Browse the repository at this point in the history
file: don't crash on cleanup with query_on_cache_miss: no
  • Loading branch information
pro-wh authored May 4, 2023
2 parents 1240f01 + 326e664 commit f1a916f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion storage/oasis/nodeapi/file/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ func NewFileConsensusApiLite(cacheDir string, consensusApi nodeapi.ConsensusApiL

func (c *FileConsensusApiLite) Close() error {
// Close all resources and return the first encountered error, if any.
firstErr := c.consensusApi.Close()
var firstErr error
if c.consensusApi != nil {
firstErr = c.consensusApi.Close()
}
if err := c.db.Close(); err != nil && firstErr == nil {
firstErr = err
}
Expand Down
5 changes: 4 additions & 1 deletion storage/oasis/nodeapi/file/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ func NewFileRuntimeApiLite(runtime common.Runtime, cacheDir string, runtimeApi n

func (r *FileRuntimeApiLite) Close() error {
// Close all resources and return the first encountered error, if any.
firstErr := r.runtimeApi.Close()
var firstErr error
if r.runtimeApi != nil {
firstErr = r.runtimeApi.Close()
}
if err := r.db.Close(); err != nil && firstErr == nil {
firstErr = err
}
Expand Down

0 comments on commit f1a916f

Please sign in to comment.