mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
fix(eventlog) configure logging if repo is initialized
License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
This commit is contained in:
parent
6c94a0715f
commit
2c38487eb0
@ -24,6 +24,7 @@ import (
|
||||
u "github.com/jbenet/go-ipfs/util"
|
||||
"github.com/jbenet/go-ipfs/util/debugerror"
|
||||
eventlog "github.com/jbenet/go-ipfs/util/eventlog"
|
||||
repo "github.com/jbenet/go-ipfs/repo"
|
||||
)
|
||||
|
||||
// log is the command logger
|
||||
@ -271,7 +272,7 @@ func callPreCommandHooks(details cmdDetails, req cmds.Request, root *cmds.Comman
|
||||
|
||||
// When the upcoming command may use the config and repo, we know it's safe
|
||||
// for the log config hook to touch the config/repo
|
||||
if details.usesConfigAsInput() && details.usesRepo() {
|
||||
if repo.IsInitialized(req.Context().ConfigRoot) {
|
||||
log.Debug("Calling hook: Configure Event Logger")
|
||||
cfg, err := req.Context().GetConfig()
|
||||
if err != nil {
|
||||
|
||||
15
repo/repo.go
Normal file
15
repo/repo.go
Normal file
@ -0,0 +1,15 @@
|
||||
package repo
|
||||
|
||||
import util "github.com/jbenet/go-ipfs/util"
|
||||
|
||||
// IsInitialized returns true if the path is home to an initialized IPFS
|
||||
// repository.
|
||||
func IsInitialized(path string) bool {
|
||||
if !util.FileExists(path) {
|
||||
return false
|
||||
}
|
||||
// TODO add logging check
|
||||
// TODO add datastore check
|
||||
// TODO add config file check
|
||||
return true
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user