1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-26 23:53:19 +08:00

Merge pull request #5022 from Bren2010/review/cmd/ipfs

Remove leftover bits of code.
This commit is contained in:
Whyrusleeping
2018-05-28 06:14:44 +01:00
committed by GitHub
4 changed files with 10 additions and 43 deletions

View File

@ -301,10 +301,6 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
}
routingOption, _ := req.Options[routingOptionKwd].(string)
if err != nil {
re.SetError(err, cmdkit.ErrNormal)
return
}
if routingOption == routingOptionDefaultKwd {
cfg, err := repo.Config()
if err != nil {

View File

@ -26,7 +26,6 @@ var localCommands = map[string]*cmds.Command{
"init": initCmd,
"commands": commandsClientCmd,
}
var localMap = make(map[*cmds.Command]bool)
func init() {
// setting here instead of in literal to prevent initialization loop
@ -38,10 +37,6 @@ func init() {
Root.Subcommands[k] = v
}
}
for _, v := range localCommands {
localMap[v] = true
}
}
// NB: when necessary, properties are described using negatives in order to

View File

@ -92,6 +92,7 @@ func mainRet() int {
os.Args[0] = "ipfs"
buildEnv := func(ctx context.Context, req *cmds.Request) (cmds.Environment, error) {
checkDebug(req)
repoPath, err := getRepoPath(req)
if err != nil {
return nil, err
@ -151,12 +152,7 @@ func checkDebug(req *cmds.Request) {
}
func makeExecutor(req *cmds.Request, env interface{}) (cmds.Executor, error) {
checkDebug(req)
details, err := commandDetails(req.Path, Root)
if err != nil {
return nil, err
}
details := commandDetails(req.Path)
client, err := commandShouldRunOnDaemon(*details, req, env.(*oldcmds.Context))
if err != nil {
return nil, err
@ -200,25 +196,16 @@ func checkPermissions(path string) (bool, error) {
return true, nil
}
// commandDetails returns a command's details for the command given by |path|
// within the |root| command tree.
//
// Returns an error if the command is not found in the Command tree.
func commandDetails(path []string, root *cmds.Command) (*cmdDetails, error) {
// commandDetails returns a command's details for the command given by |path|.
func commandDetails(path []string) *cmdDetails {
var details cmdDetails
// find the last command in path that has a cmdDetailsMap entry
cmd := root
for _, cmp := range path {
cmd = cmd.Subcommands[cmp]
if cmd == nil {
return nil, fmt.Errorf("subcommand %s should be in root", cmp)
}
if cmdDetails, found := cmdDetailsMap[strings.Join(path, "/")]; found {
for i := range path {
if cmdDetails, found := cmdDetailsMap[strings.Join(path[:i+1], "/")]; found {
details = cmdDetails
}
}
return &details, nil
return &details
}
// commandShouldRunOnDaemon determines, from command details, whether a
@ -318,7 +305,7 @@ func startProfiling() (func(), error) {
stopProfiling := func() {
pprof.StopCPUProfile()
defer ofi.Close() // captured by the closure
ofi.Close() // captured by the closure
}
return stopProfiling, nil
}

View File

@ -597,12 +597,7 @@ func (n *IpfsNode) teardown() error {
// OnlineMode returns whether or not the IpfsNode is in OnlineMode.
func (n *IpfsNode) OnlineMode() bool {
switch n.mode {
case onlineMode:
return true
default:
return false
}
return n.mode == onlineMode
}
// SetLocal will set the IpfsNode to local mode
@ -619,17 +614,11 @@ func (n *IpfsNode) LocalMode() bool {
// programmer error should not happen
panic("local mode not set")
}
switch n.mode {
case localMode:
return true
default:
return false
}
return n.mode == localMode
}
// Bootstrap will set and call the IpfsNodes bootstrap function.
func (n *IpfsNode) Bootstrap(cfg BootstrapConfig) error {
// TODO what should return value be when in offlineMode?
if n.Routing == nil {
return nil