mirror of
https://github.com/ipfs/kubo.git
synced 2025-10-19 20:53:04 +08:00
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: Kevin Atkinson <k@kevina.org>
This commit is contained in:

committed by
Michael Muré

parent
cac995e704
commit
eeb15db140
@ -31,7 +31,7 @@ import (
|
|||||||
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
|
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = logging.Logger("cmds/files")
|
var flog = logging.Logger("cmds/files")
|
||||||
|
|
||||||
var FilesCmd = &cmds.Command{
|
var FilesCmd = &cmds.Command{
|
||||||
Helptext: cmdkit.HelpText{
|
Helptext: cmdkit.HelpText{
|
||||||
@ -768,7 +768,7 @@ stat' on the file or any of its ancestors.
|
|||||||
|
|
||||||
_, err = wfd.Seek(int64(offset), io.SeekStart)
|
_, err = wfd.Seek(int64(offset), io.SeekStart)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("seekfail: ", err)
|
flog.Error("seekfail: ", err)
|
||||||
res.SetError(err, cmdkit.ErrNormal)
|
res.SetError(err, cmdkit.ErrNormal)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1112,7 +1112,7 @@ func getFileHandle(r *mfs.Root, path string, create bool, prefix *cid.Prefix) (*
|
|||||||
dirname, fname := gopath.Split(path)
|
dirname, fname := gopath.Split(path)
|
||||||
pdiri, err := mfs.Lookup(r, dirname)
|
pdiri, err := mfs.Lookup(r, dirname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("lookupfail ", dirname)
|
flog.Error("lookupfail ", dirname)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
pdir, ok := pdiri.(*mfs.Directory)
|
pdir, ok := pdiri.(*mfs.Directory)
|
||||||
@ -1161,17 +1161,3 @@ func checkPath(p string) (string, error) {
|
|||||||
}
|
}
|
||||||
return cleaned, nil
|
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
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
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"
|
oldcmds "github.com/ipfs/go-ipfs/commands"
|
||||||
dag "github.com/ipfs/go-ipfs/core/commands/dag"
|
dag "github.com/ipfs/go-ipfs/core/commands/dag"
|
||||||
e "github.com/ipfs/go-ipfs/core/commands/e"
|
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"
|
ocmd "github.com/ipfs/go-ipfs/core/commands/object"
|
||||||
unixfs "github.com/ipfs/go-ipfs/core/commands/unixfs"
|
unixfs "github.com/ipfs/go-ipfs/core/commands/unixfs"
|
||||||
|
|
||||||
@ -109,7 +108,7 @@ var rootSubcommands = map[string]*cmds.Command{
|
|||||||
"block": BlockCmd,
|
"block": BlockCmd,
|
||||||
"cat": CatCmd,
|
"cat": CatCmd,
|
||||||
"commands": CommandsDaemonCmd,
|
"commands": CommandsDaemonCmd,
|
||||||
"files": files.FilesCmd,
|
"files": FilesCmd,
|
||||||
"filestore": FileStoreCmd,
|
"filestore": FileStoreCmd,
|
||||||
"get": GetCmd,
|
"get": GetCmd,
|
||||||
"pubsub": PubsubCmd,
|
"pubsub": PubsubCmd,
|
||||||
|
Reference in New Issue
Block a user