mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-01 10:49:24 +08:00
core/commands2: Output error when trying to run 'publish' or 'resolve' in offline mode
This commit is contained in:

committed by
Juan Batiz-Benet

parent
51c6a1c552
commit
af65eec2fc
@ -20,6 +20,8 @@ type ResolveOutput struct {
|
|||||||
Entries []IpnsEntry
|
Entries []IpnsEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errNotOnline = errors.New("This command must be run in online mode. Try running 'ipfs daemon' first.")
|
||||||
|
|
||||||
var nameCmd = &cmds.Command{
|
var nameCmd = &cmds.Command{
|
||||||
Help: "TODO",
|
Help: "TODO",
|
||||||
Subcommands: map[string]*cmds.Command{
|
Subcommands: map[string]*cmds.Command{
|
||||||
@ -38,6 +40,11 @@ var publishCmd = &cmds.Command{
|
|||||||
n := req.Context().Node
|
n := req.Context().Node
|
||||||
args := req.Arguments()
|
args := req.Arguments()
|
||||||
|
|
||||||
|
if n.Network == nil {
|
||||||
|
res.SetError(errNotOnline, cmds.ErrNormal)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if n.Identity == nil {
|
if n.Identity == nil {
|
||||||
res.SetError(errors.New("Identity not loaded!"), cmds.ErrNormal)
|
res.SetError(errors.New("Identity not loaded!"), cmds.ErrNormal)
|
||||||
return
|
return
|
||||||
@ -86,6 +93,11 @@ var resolveCmd = &cmds.Command{
|
|||||||
n := req.Context().Node
|
n := req.Context().Node
|
||||||
var names []string
|
var names []string
|
||||||
|
|
||||||
|
if n.Network == nil {
|
||||||
|
res.SetError(errNotOnline, cmds.ErrNormal)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if len(req.Arguments()) == 0 {
|
if len(req.Arguments()) == 0 {
|
||||||
if n.Identity == nil {
|
if n.Identity == nil {
|
||||||
res.SetError(errors.New("Identity not loaded!"), cmds.ErrNormal)
|
res.SetError(errors.New("Identity not loaded!"), cmds.ErrNormal)
|
||||||
|
Reference in New Issue
Block a user