Skip to content

Commit

Permalink
only construct a node in online mode when running external commands.
Browse files Browse the repository at this point in the history
This breaks commands like `ipfs update` that expect IPFS to *not* be running.

fixes #5191

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
  • Loading branch information
Stebalien committed Jul 5, 2018
1 parent 7e8f6c9 commit b6081be
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions core/commands/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,16 @@ func ExternalBinary() *cmds.Command {
// setup env of child program
env := os.Environ()

nd, err := req.InvocContext().GetNode()
if err == nil {
// Get the node iff already defined.
if req.InvocContext().Online {
nd, err := req.InvocContext().GetNode()
if err != nil {
res.SetError(fmt.Errorf(
"failed to start ipfs node: %s",
err,
), cmdkit.ErrFatal)
return
}
env = append(env, fmt.Sprintf("IPFS_ONLINE=%t", nd.OnlineMode()))
}

Expand Down

0 comments on commit b6081be

Please sign in to comment.