1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-08-06 19:44:01 +08:00

fix(core/commands): do not cache config (#8824)

This commit is contained in:
Lucas Molas
2022-03-27 09:11:45 -03:00
committed by GitHub
parent d13a09a076
commit d92887086f
9 changed files with 9 additions and 66 deletions

View File

@ -25,7 +25,6 @@ import (
"github.com/ipfs/go-ipfs-cmds/cli"
cmdhttp "github.com/ipfs/go-ipfs-cmds/http"
u "github.com/ipfs/go-ipfs-util"
config "github.com/ipfs/go-ipfs/config"
logging "github.com/ipfs/go-log"
loggables "github.com/libp2p/go-libp2p-loggables"
ma "github.com/multiformats/go-multiaddr"
@ -138,7 +137,6 @@ func mainRet() int {
// this is so that we can construct the node lazily.
return &oldcmds.Context{
ConfigRoot: repoPath,
LoadConfig: loadConfig,
ReqLog: &oldcmds.ReqLog{},
Plugins: plugins,
ConstructNode: func() (n *core.IpfsNode, err error) {
@ -306,10 +304,6 @@ func getRepoPath(req *cmds.Request) (string, error) {
return repoPath, nil
}
func loadConfig(path string) (*config.Config, error) {
return fsrepo.ConfigAt(path)
}
// startProfiling begins CPU profiling and returns a `stop` function to be
// executed as late as possible. The stop function captures the memprofile.
func startProfiling() (func(), error) {

View File

@ -36,7 +36,7 @@ const defaultRepinInterval = 5 * time.Minute
type pinMFSContext interface {
Context() context.Context
GetConfigNoCache() (*config.Config, error)
GetConfig() (*config.Config, error)
}
type pinMFSNode interface {
@ -104,7 +104,7 @@ func pinMFSOnChange(configPollInterval time.Duration, cctx pinMFSContext, node p
}
// reread the config, which may have changed in the meantime
cfg, err := cctx.GetConfigNoCache()
cfg, err := cctx.GetConfig()
if err != nil {
select {
case errCh <- fmt.Errorf("pinning reading config (%v)", err):

View File

@ -24,7 +24,7 @@ func (x *testPinMFSContext) Context() context.Context {
return x.ctx
}
func (x *testPinMFSContext) GetConfigNoCache() (*config.Config, error) {
func (x *testPinMFSContext) GetConfig() (*config.Config, error) {
return x.cfg, x.err
}

View File

@ -20,7 +20,6 @@ import (
fsnotify "github.com/fsnotify/fsnotify"
files "github.com/ipfs/go-ipfs-files"
config "github.com/ipfs/go-ipfs/config"
process "github.com/jbenet/goprocess"
homedir "github.com/mitchellh/go-homedir"
)
@ -217,9 +216,6 @@ func IsHidden(path string) bool {
func cmdCtx(node *core.IpfsNode, repoPath string) commands.Context {
return commands.Context{
ConfigRoot: repoPath,
LoadConfig: func(path string) (*config.Config, error) {
return node.Repo.Config()
},
ConstructNode: func() (*core.IpfsNode, error) {
return node, nil
},