fix(eventlog) configure logging if repo is initialized

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
This commit is contained in:
Brian Tiger Chow 2014-11-22 23:22:21 -08:00
parent 6c94a0715f
commit 2c38487eb0
2 changed files with 17 additions and 1 deletions

View File

@ -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
View 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
}