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>
Kevin Atkinson committed
Feb 1, 2018 at 15:51 UTC
eeb15db140c48ec3f003fb6573def4f9fd2bb801
3 files changed
+4
-48
core/commands/files.go
renamed
+3
-17
@@ -31,7 +31,7 @@ import (
31
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
32
)
33
34
-var log = logging.Logger("cmds/files")
34
+var flog = logging.Logger("cmds/files")
35
36
var FilesCmd = &cmds.Command{
37
Helptext: cmdkit.HelpText{
@@ -768,7 +768,7 @@ stat' on the file or any of its ancestors.
768
769
_, err = wfd.Seek(int64(offset), io.SeekStart)
770
if err != nil {
771
- log.Error("seekfail: ", err)
771
+ flog.Error("seekfail: ", err)
772
res.SetError(err, cmdkit.ErrNormal)
773
return
774
}
@@ -1112,7 +1112,7 @@ func getFileHandle(r *mfs.Root, path string, create bool, prefix *cid.Prefix) (*
1112
dirname, fname := gopath.Split(path)
1113
pdiri, err := mfs.Lookup(r, dirname)
1114
if err != nil {
1115
- log.Error("lookupfail ", dirname)
1115
+ flog.Error("lookupfail ", dirname)
1116
return nil, err
1117
}
1118
pdir, ok := pdiri.(*mfs.Directory)
@@ -1161,17 +1161,3 @@ func checkPath(p string) (string, error) {
1161
}
1162
return cleaned, nil
1163
}
1164
-
1165
-// copy+pasted from ../commands.go
1166
-func unwrapOutput(i interface{}) (interface{}, error) {
1167
- var (
1168
- ch <-chan interface{}
1169
- ok bool
1170
- )
1171
-
1172
- if ch, ok = i.(<-chan interface{}); !ok {
1173
- return nil, e.TypeErr(ch, i)
1174
- }
1175
-
1176
- return <-ch, nil
1177
-}
core/commands/files/env.go
deleted
-29
@@ -1,29 +0,0 @@
1
-package commands
2
-
3
-import (
4
- "fmt"
5
-
6
- "github.com/ipfs/go-ipfs/commands"
7
- "github.com/ipfs/go-ipfs/core"
8
- "github.com/ipfs/go-ipfs/repo/config"
9
-)
10
-
11
-// GetNode extracts the node from the environment.
12
-func GetNode(env interface{}) (*core.IpfsNode, error) {
13
- ctx, ok := env.(*commands.Context)
14
- if !ok {
15
- return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env)
16
- }
17
-
18
- return ctx.GetNode()
19
-}
20
-
21
-// GetConfig extracts the config from the environment.
22
-func GetConfig(env interface{}) (*config.Config, error) {
23
- ctx, ok := env.(*commands.Context)
24
- if !ok {
25
- return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env)
26
- }
27
-
28
- return ctx.GetConfig()
29
-}
core/commands/root.go
+1
-2
@@ -7,7 +7,6 @@ import (
7
oldcmds "github.com/ipfs/go-ipfs/commands"
8
dag "github.com/ipfs/go-ipfs/core/commands/dag"
9
e "github.com/ipfs/go-ipfs/core/commands/e"
10
- files "github.com/ipfs/go-ipfs/core/commands/files"
10
ocmd "github.com/ipfs/go-ipfs/core/commands/object"
11
unixfs "github.com/ipfs/go-ipfs/core/commands/unixfs"
12
@@ -109,7 +108,7 @@ var rootSubcommands = map[string]*cmds.Command{
108
"block": BlockCmd,
109
"cat": CatCmd,
110
"commands": CommandsDaemonCmd,
112
- "files": files.FilesCmd,
111
+ "files": FilesCmd,
112
"filestore": FileStoreCmd,
113
"get": GetCmd,
114
"pubsub": PubsubCmd,