fix(eventlog) configure logging if repo is initialized
License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
Brian Tiger Chow committed
Nov 22, 2014 at 23:22 UTC
2c38487eb04867d221067956c2aa35931d1795c7
2 files changed
+17
-1
cmd/ipfs/main.go
+2
-1
@@ -24,6 +24,7 @@ import (
24
u "github.com/jbenet/go-ipfs/util"
25
"github.com/jbenet/go-ipfs/util/debugerror"
26
eventlog "github.com/jbenet/go-ipfs/util/eventlog"
27
+ repo "github.com/jbenet/go-ipfs/repo"
28
)
29
30
// log is the command logger
@@ -271,7 +272,7 @@ func callPreCommandHooks(details cmdDetails, req cmds.Request, root *cmds.Comman
272
273
// When the upcoming command may use the config and repo, we know it's safe
274
// for the log config hook to touch the config/repo
274
- if details.usesConfigAsInput() && details.usesRepo() {
275
+ if repo.IsInitialized(req.Context().ConfigRoot) {
276
log.Debug("Calling hook: Configure Event Logger")
277
cfg, err := req.Context().GetConfig()
278
if err != nil {
repo/repo.go
new
+15
@@ -0,0 +1,15 @@
1
+package repo
2
+
3
+import util "github.com/jbenet/go-ipfs/util"
4
+
5
+// IsInitialized returns true if the path is home to an initialized IPFS
6
+// repository.
7
+func IsInitialized(path string) bool {
8
+ if !util.FileExists(path) {
9
+ return false
10
+ }
11
+ // TODO add logging check
12
+ // TODO add datastore check
13
+ // TODO add config file check
14
+ return true
15
+}