repo: Close datastore in Close

This commit is contained in:
Łukasz Magiera 2019-09-17 16:34:22 +02:00
parent 83f1a336a6
commit f2ecb772fa
3 changed files with 9 additions and 5 deletions

View File

@ -6,14 +6,13 @@ import (
"context"
"io/ioutil"
"github.com/filecoin-project/go-lotus/api"
"github.com/filecoin-project/go-lotus/node/modules"
"github.com/filecoin-project/go-lotus/node/modules/testing"
"github.com/multiformats/go-multiaddr"
"gopkg.in/urfave/cli.v2"
"github.com/filecoin-project/go-lotus/api"
"github.com/filecoin-project/go-lotus/node"
"github.com/filecoin-project/go-lotus/node/modules"
"github.com/filecoin-project/go-lotus/node/modules/testing"
"github.com/filecoin-project/go-lotus/node/repo"
)

View File

@ -57,7 +57,7 @@ type clientRequest struct {
// ClientCloser is used to close Client from further use
type ClientCloser func()
// NewClient creates new josnrpc 2.0 client
// NewClient creates new jsonrpc 2.0 client
//
// handler must be pointer to a struct with function fields
// Returned value closes the client connection

View File

@ -181,6 +181,11 @@ func (fsr *fsLockedRepo) Close() error {
if err != nil && !os.IsNotExist(err) {
return xerrors.Errorf("could not remove API file: %w", err)
}
if fsr.ds != nil {
if err := fsr.ds.Close(); err != nil {
return xerrors.Errorf("could not close datastore: %w", err)
}
}
err = fsr.closer.Close()
fsr.closer = nil