Unverified 提交 eeb15db1 作者: Kevin Atkinson 提交者: Michael Muré

Move files.go out of its own directory.

It is a single file so putting it in its own package is a bit of an
overkill.

License: MIT
Signed-off-by: 's avatarKevin Atkinson <k@kevina.org>
上级 cac995e7
......@@ -31,7 +31,7 @@ import (
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
)
var log = logging.Logger("cmds/files")
var flog = logging.Logger("cmds/files")
var FilesCmd = &cmds.Command{
Helptext: cmdkit.HelpText{
......@@ -768,7 +768,7 @@ stat' on the file or any of its ancestors.
_, err = wfd.Seek(int64(offset), io.SeekStart)
if err != nil {
log.Error("seekfail: ", err)
flog.Error("seekfail: ", err)
res.SetError(err, cmdkit.ErrNormal)
return
}
......@@ -1112,7 +1112,7 @@ func getFileHandle(r *mfs.Root, path string, create bool, prefix *cid.Prefix) (*
dirname, fname := gopath.Split(path)
pdiri, err := mfs.Lookup(r, dirname)
if err != nil {
log.Error("lookupfail ", dirname)
flog.Error("lookupfail ", dirname)
return nil, err
}
pdir, ok := pdiri.(*mfs.Directory)
......@@ -1161,17 +1161,3 @@ func checkPath(p string) (string, error) {
}
return cleaned, nil
}
// copy+pasted from ../commands.go
func unwrapOutput(i interface{}) (interface{}, error) {
var (
ch <-chan interface{}
ok bool
)
if ch, ok = i.(<-chan interface{}); !ok {
return nil, e.TypeErr(ch, i)
}
return <-ch, nil
}
package commands
import (
"fmt"
"github.com/ipfs/go-ipfs/commands"
"github.com/ipfs/go-ipfs/core"
"github.com/ipfs/go-ipfs/repo/config"
)
// GetNode extracts the node from the environment.
func GetNode(env interface{}) (*core.IpfsNode, error) {
ctx, ok := env.(*commands.Context)
if !ok {
return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env)
}
return ctx.GetNode()
}
// GetConfig extracts the config from the environment.
func GetConfig(env interface{}) (*config.Config, error) {
ctx, ok := env.(*commands.Context)
if !ok {
return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env)
}
return ctx.GetConfig()
}
......@@ -7,7 +7,6 @@ import (
oldcmds "github.com/ipfs/go-ipfs/commands"
dag "github.com/ipfs/go-ipfs/core/commands/dag"
e "github.com/ipfs/go-ipfs/core/commands/e"
files "github.com/ipfs/go-ipfs/core/commands/files"
ocmd "github.com/ipfs/go-ipfs/core/commands/object"
unixfs "github.com/ipfs/go-ipfs/core/commands/unixfs"
......@@ -109,7 +108,7 @@ var rootSubcommands = map[string]*cmds.Command{
"block": BlockCmd,
"cat": CatCmd,
"commands": CommandsDaemonCmd,
"files": files.FilesCmd,
"files": FilesCmd,
"filestore": FileStoreCmd,
"get": GetCmd,
"pubsub": PubsubCmd,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论