From 2c38487eb04867d221067956c2aa35931d1795c7 Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Sat, 22 Nov 2014 23:22:21 -0800 Subject: [PATCH] fix(eventlog) configure logging if repo is initialized License: MIT Signed-off-by: Brian Tiger Chow --- cmd/ipfs/main.go | 3 ++- repo/repo.go | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 repo/repo.go diff --git a/cmd/ipfs/main.go b/cmd/ipfs/main.go index 991385435..0ca8044f2 100644 --- a/cmd/ipfs/main.go +++ b/cmd/ipfs/main.go @@ -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 { diff --git a/repo/repo.go b/repo/repo.go new file mode 100644 index 000000000..6d702d9ac --- /dev/null +++ b/repo/repo.go @@ -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 +}