@cryptotaxi247 / kubo / commits / 667b7f992

coreiface: updates for moving path to subpackage

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>

Łukasz Magiera committed Mar 26, 2019 at 14:56 UTC 667b7f9927801c7ef170c1f399254028833244f0
26 files changed +120 -105
assets/assets.go
+2 -2
@@ -13,8 +13,8 @@ import (
13
14 cid "github.com/ipfs/go-cid"
15 files "github.com/ipfs/go-ipfs-files"
16 - iface "github.com/ipfs/interface-go-ipfs-core"
16 options "github.com/ipfs/interface-go-ipfs-core/options"
17 + "github.com/ipfs/interface-go-ipfs-core/path"
18
19 // this import keeps gx from thinking the dep isn't used
20 _ "github.com/ipfs/dir-index-html"
@@ -57,7 +57,7 @@ func addAssetList(nd *core.IpfsNode, l []string) (cid.Cid, error) {
57 return cid.Cid{}, err
58 }
59
60 - basePath := iface.IpfsPath(dirb.Cid())
60 + basePath := path.IpfsPath(dirb.Cid())
61
62 for _, p := range l {
63 d, err := Asset(p)
core/commands/block.go
+4 -4
@@ -11,8 +11,8 @@ import (
11
12 cmdkit "github.com/ipfs/go-ipfs-cmdkit"
13 cmds "github.com/ipfs/go-ipfs-cmds"
14 - coreiface "github.com/ipfs/interface-go-ipfs-core"
14 options "github.com/ipfs/interface-go-ipfs-core/options"
15 + path "github.com/ipfs/interface-go-ipfs-core/path"
16 mh "github.com/multiformats/go-multihash"
17 )
18
@@ -65,7 +65,7 @@ on raw IPFS blocks. It outputs the following to stdout:
65 return err
66 }
67
68 - b, err := api.Block().Stat(req.Context, coreiface.ParsePath(req.Arguments[0]))
68 + b, err := api.Block().Stat(req.Context, path.ParsePath(req.Arguments[0]))
69 if err != nil {
70 return err
71 }
@@ -102,7 +102,7 @@ It outputs to stdout, and <key> is a base58 encoded multihash.
102 return err
103 }
104
105 - r, err := api.Block().Get(req.Context, coreiface.ParsePath(req.Arguments[0]))
105 + r, err := api.Block().Get(req.Context, path.ParsePath(req.Arguments[0]))
106 if err != nil {
107 return err
108 }
@@ -224,7 +224,7 @@ It takes a list of base58 encoded multihashes to remove.
224
225 // TODO: use batching coreapi when done
226 for _, b := range req.Arguments {
227 - rp, err := api.ResolvePath(req.Context, coreiface.ParsePath(b))
227 + rp, err := api.ResolvePath(req.Context, path.ParsePath(b))
228
229 err = api.Block().Rm(req.Context, rp, options.Block.Force(force))
230 if err != nil {
core/commands/cat.go
+2 -1
@@ -12,6 +12,7 @@ import (
12 cmds "github.com/ipfs/go-ipfs-cmds"
13 "github.com/ipfs/go-ipfs-files"
14 "github.com/ipfs/interface-go-ipfs-core"
15 + "github.com/ipfs/interface-go-ipfs-core/path"
16 )
17
18 const (
@@ -118,7 +119,7 @@ func cat(ctx context.Context, api iface.CoreAPI, paths []string, offset int64, m
119 return nil, 0, nil
120 }
121 for _, p := range paths {
121 - f, err := api.Unixfs().Get(ctx, iface.ParsePath(p))
122 + f, err := api.Unixfs().Get(ctx, path.ParsePath(p))
123 if err != nil {
124 return nil, 0, err
125 }
core/commands/dag/dag.go
+3 -4
@@ -15,8 +15,7 @@ import (
15 cmds "github.com/ipfs/go-ipfs-cmds"
16 files "github.com/ipfs/go-ipfs-files"
17 ipld "github.com/ipfs/go-ipld-format"
18 - path "github.com/ipfs/go-path"
19 - iface "github.com/ipfs/interface-go-ipfs-core"
18 + path "github.com/ipfs/interface-go-ipfs-core/path"
19 mh "github.com/multiformats/go-multihash"
20 )
21
@@ -160,7 +159,7 @@ format.
159 return err
160 }
161
163 - rp, err := api.ResolvePath(req.Context, iface.ParsePath(req.Arguments[0]))
162 + rp, err := api.ResolvePath(req.Context, path.ParsePath(req.Arguments[0]))
163 if err != nil {
164 return err
165 }
@@ -200,7 +199,7 @@ var DagResolveCmd = &cmds.Command{
199 return err
200 }
201
203 - rp, err := api.ResolvePath(req.Context, iface.ParsePath(req.Arguments[0]))
202 + rp, err := api.ResolvePath(req.Context, path.ParsePath(req.Arguments[0]))
203 if err != nil {
204 return err
205 }
core/commands/files.go
+2 -1
@@ -26,6 +26,7 @@ import (
26 "github.com/ipfs/go-mfs"
27 ft "github.com/ipfs/go-unixfs"
28 "github.com/ipfs/interface-go-ipfs-core"
29 + path "github.com/ipfs/interface-go-ipfs-core/path"
30 mh "github.com/multiformats/go-multihash"
31 )
32
@@ -363,7 +364,7 @@ var filesCpCmd = &cmds.Command{
364 func getNodeFromPath(ctx context.Context, node *core.IpfsNode, api iface.CoreAPI, p string) (ipld.Node, error) {
365 switch {
366 case strings.HasPrefix(p, "/ipfs/"):
366 - return api.ResolveNode(ctx, iface.ParsePath(p))
367 + return api.ResolveNode(ctx, path.ParsePath(p))
368 default:
369 fsn, err := mfs.Lookup(node.FilesRoot, p)
370 if err != nil {
core/commands/get.go
+5 -5
@@ -7,7 +7,7 @@ import (
7 "fmt"
8 "io"
9 "os"
10 - "path"
10 + gopath "path"
11 "path/filepath"
12 "strings"
13
@@ -17,7 +17,7 @@ import (
17 cmdkit "github.com/ipfs/go-ipfs-cmdkit"
18 cmds "github.com/ipfs/go-ipfs-cmds"
19 files "github.com/ipfs/go-ipfs-files"
20 - iface "github.com/ipfs/interface-go-ipfs-core"
20 + "github.com/ipfs/interface-go-ipfs-core/path"
21 "github.com/whyrusleeping/tar-utils"
22 "gopkg.in/cheggaaa/pb.v1"
23 )
@@ -71,7 +71,7 @@ may also specify the level of compression by specifying '-l=<1-9>'.
71 return err
72 }
73
74 - p := iface.ParsePath(req.Arguments[0])
74 + p := path.ParsePath(req.Arguments[0])
75
76 file, err := api.Unixfs().Get(req.Context, p)
77 if err != nil {
@@ -264,8 +264,8 @@ func (i *identityWriteCloser) Close() error {
264 }
265
266 func fileArchive(f files.Node, name string, archive bool, compression int) (io.Reader, error) {
267 - cleaned := path.Clean(name)
268 - _, filename := path.Split(cleaned)
267 + cleaned := gopath.Clean(name)
268 + _, filename := gopath.Split(cleaned)
269
270 // need to connect a writer to a reader
271 piper, pipew := io.Pipe()
core/commands/ls.go
+2 -1
@@ -15,6 +15,7 @@ import (
15 unixfs_pb "github.com/ipfs/go-unixfs/pb"
16 iface "github.com/ipfs/interface-go-ipfs-core"
17 options "github.com/ipfs/interface-go-ipfs-core/options"
18 + path "github.com/ipfs/interface-go-ipfs-core/path"
19 )
20
21 // LsLink contains printable data for a single ipld link in ls output
@@ -131,7 +132,7 @@ The JSON output contains type information.
132 }
133
134 for i, fpath := range paths {
134 - results, err := api.Unixfs().Ls(req.Context, iface.ParsePath(fpath),
135 + results, err := api.Unixfs().Ls(req.Context, path.ParsePath(fpath),
136 options.Unixfs.ResolveChildren(resolveSize || resolveType))
137 if err != nil {
138 return err
core/commands/name/publish.go
+2 -1
@@ -12,6 +12,7 @@ import (
12 cmds "github.com/ipfs/go-ipfs-cmds"
13 iface "github.com/ipfs/interface-go-ipfs-core"
14 options "github.com/ipfs/interface-go-ipfs-core/options"
15 + path "github.com/ipfs/interface-go-ipfs-core/path"
16 )
17
18 var (
@@ -112,7 +113,7 @@ Alternatively, publish an <ipfs-path> using a valid PeerID (as listed by
113 opts = append(opts, options.Name.TTL(d))
114 }
115
115 - p := iface.ParsePath(req.Arguments[0])
116 + p := path.ParsePath(req.Arguments[0])
117
118 if verifyExists, _ := req.Options[resolveOptionName].(bool); verifyExists {
119 _, err := api.ResolveNode(req.Context, p)
core/commands/object/diff.go
+3 -3
@@ -9,7 +9,7 @@ import (
9
10 cmdkit "github.com/ipfs/go-ipfs-cmdkit"
11 cmds "github.com/ipfs/go-ipfs-cmds"
12 - coreiface "github.com/ipfs/interface-go-ipfs-core"
12 + path "github.com/ipfs/interface-go-ipfs-core/path"
13 )
14
15 const (
@@ -60,8 +60,8 @@ Example:
60 return err
61 }
62
63 - pa := coreiface.ParsePath(req.Arguments[0])
64 - pb := coreiface.ParsePath(req.Arguments[1])
63 + pa := path.ParsePath(req.Arguments[0])
64 + pb := path.ParsePath(req.Arguments[1])
65
66 changes, err := api.Object().Diff(req.Context, pa, pb)
67 if err != nil {
core/commands/object/object.go
+5 -5
@@ -15,8 +15,8 @@ import (
15 "github.com/ipfs/go-ipfs-cmds"
16 ipld "github.com/ipfs/go-ipld-format"
17 dag "github.com/ipfs/go-merkledag"
18 - coreiface "github.com/ipfs/interface-go-ipfs-core"
18 "github.com/ipfs/interface-go-ipfs-core/options"
19 + path "github.com/ipfs/interface-go-ipfs-core/path"
20 )
21
22 type Node struct {
@@ -91,7 +91,7 @@ is the raw data of the object.
91 return err
92 }
93
94 - path := coreiface.ParsePath(req.Arguments[0])
94 + path := path.ParsePath(req.Arguments[0])
95
96 data, err := api.Object().Data(req.Context, path)
97 if err != nil {
@@ -130,7 +130,7 @@ multihash.
130 return err
131 }
132
133 - path := coreiface.ParsePath(req.Arguments[0])
133 + path := path.ParsePath(req.Arguments[0])
134
135 rp, err := api.ResolvePath(req.Context, path)
136 if err != nil {
@@ -222,7 +222,7 @@ Supported values are:
222 return err
223 }
224
225 - path := coreiface.ParsePath(req.Arguments[0])
225 + path := path.ParsePath(req.Arguments[0])
226
227 datafieldenc, _ := req.Options[encodingOptionName].(string)
228 if err != nil {
@@ -314,7 +314,7 @@ var ObjectStatCmd = &cmds.Command{
314 return err
315 }
316
317 - ns, err := api.Object().Stat(req.Context, coreiface.ParsePath(req.Arguments[0]))
317 + ns, err := api.Object().Stat(req.Context, path.ParsePath(req.Arguments[0]))
318 if err != nil {
319 return err
320 }
core/commands/object/patch.go
+6 -6
@@ -8,8 +8,8 @@ import (
8
9 "github.com/ipfs/go-ipfs-cmdkit"
10 "github.com/ipfs/go-ipfs-cmds"
11 - coreiface "github.com/ipfs/interface-go-ipfs-core"
11 "github.com/ipfs/interface-go-ipfs-core/options"
12 + "github.com/ipfs/interface-go-ipfs-core/path"
13 )
14
15 var ObjectPatchCmd = &cmds.Command{
@@ -55,7 +55,7 @@ the limit will not be respected by the network.
55 return err
56 }
57
58 - root := coreiface.ParsePath(req.Arguments[0])
58 + root := path.ParsePath(req.Arguments[0])
59
60 file, err := cmdenv.GetFileArg(req.Files.Entries())
61 if err != nil {
@@ -99,7 +99,7 @@ Example:
99 return err
100 }
101
102 - root := coreiface.ParsePath(req.Arguments[0])
102 + root := path.ParsePath(req.Arguments[0])
103
104 file, err := cmdenv.GetFileArg(req.Files.Entries())
105 if err != nil {
@@ -139,7 +139,7 @@ Remove a Merkle-link from the given object and return the hash of the result.
139 return err
140 }
141
142 - root := coreiface.ParsePath(req.Arguments[0])
142 + root := path.ParsePath(req.Arguments[0])
143
144 name := req.Arguments[1]
145 p, err := api.Object().RmLink(req.Context, root, name)
@@ -192,9 +192,9 @@ to a file containing 'bar', and returns the hash of the new object.
192 return err
193 }
194
195 - root := coreiface.ParsePath(req.Arguments[0])
195 + root := path.ParsePath(req.Arguments[0])
196 name := req.Arguments[1]
197 - child := coreiface.ParsePath(req.Arguments[2])
197 + child := path.ParsePath(req.Arguments[2])
198
199 create, _ := req.Options[createOptionName].(bool)
200 if err != nil {
core/commands/pin.go
+6 -5
@@ -22,6 +22,7 @@ import (
22 verifcid "github.com/ipfs/go-verifcid"
23 coreiface "github.com/ipfs/interface-go-ipfs-core"
24 options "github.com/ipfs/interface-go-ipfs-core/options"
25 + "github.com/ipfs/interface-go-ipfs-core/path"
26 )
27
28 var PinCmd = &cmds.Command{
@@ -183,7 +184,7 @@ var addPinCmd = &cmds.Command{
184 func pinAddMany(ctx context.Context, api coreiface.CoreAPI, enc cidenc.Encoder, paths []string, recursive bool) ([]string, error) {
185 added := make([]string, len(paths))
186 for i, b := range paths {
186 - rp, err := api.ResolvePath(ctx, coreiface.ParsePath(b))
187 + rp, err := api.ResolvePath(ctx, path.ParsePath(b))
188 if err != nil {
189 return nil, err
190 }
@@ -233,7 +234,7 @@ collected if needed. (By default, recursively. Use -r=false for direct pins.)
234
235 pins := make([]string, 0, len(req.Arguments))
236 for _, b := range req.Arguments {
236 - rp, err := api.ResolvePath(req.Context, coreiface.ParsePath(b))
237 + rp, err := api.ResolvePath(req.Context, path.ParsePath(b))
238 if err != nil {
239 return err
240 }
@@ -407,8 +408,8 @@ new pin and removing the old one.
408
409 unpin, _ := req.Options[pinUnpinOptionName].(bool)
410
410 - from := coreiface.ParsePath(req.Arguments[0])
411 - to := coreiface.ParsePath(req.Arguments[1])
411 + from := path.ParsePath(req.Arguments[0])
412 + to := path.ParsePath(req.Arguments[1])
413
414 err = api.Pin().Update(req.Context, from, to, options.Pin.Unpin(unpin))
415 if err != nil {
@@ -497,7 +498,7 @@ func pinLsKeys(ctx context.Context, args []string, typeStr string, n *core.IpfsN
498 keys := make(map[cid.Cid]RefKeyObject)
499
500 for _, p := range args {
500 - c, err := api.ResolvePath(ctx, coreiface.ParsePath(p))
501 + c, err := api.ResolvePath(ctx, path.ParsePath(p))
502 if err != nil {
503 return nil, err
504 }
core/commands/resolve.go
+5 -5
@@ -14,10 +14,10 @@ import (
14 cidenc "github.com/ipfs/go-cidutil/cidenc"
15 cmdkit "github.com/ipfs/go-ipfs-cmdkit"
16 cmds "github.com/ipfs/go-ipfs-cmds"
17 - path "github.com/ipfs/go-path"
18 - coreiface "github.com/ipfs/interface-go-ipfs-core"
17 + ipfspath "github.com/ipfs/go-path"
18 options "github.com/ipfs/interface-go-ipfs-core/options"
19 nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys"
20 + path "github.com/ipfs/interface-go-ipfs-core/path"
21 )
22
23 const (
@@ -126,11 +126,11 @@ Resolve the value of an IPFS DAG path:
126 if err != nil && err != ns.ErrResolveRecursion {
127 return err
128 }
129 - return cmds.EmitOnce(res, &ncmd.ResolvedPath{Path: path.Path(p.String())})
129 + return cmds.EmitOnce(res, &ncmd.ResolvedPath{Path: ipfspath.Path(p.String())})
130 }
131
132 // else, ipfs path or ipns with recursive flag
133 - rp, err := api.ResolvePath(req.Context, coreiface.ParsePath(name))
133 + rp, err := api.ResolvePath(req.Context, path.ParsePath(name))
134 if err != nil {
135 return err
136 }
@@ -140,7 +140,7 @@ Resolve the value of an IPFS DAG path:
140 encoded += "/" + remainder
141 }
142
143 - return cmds.EmitOnce(res, &ncmd.ResolvedPath{Path: path.Path(encoded)})
143 + return cmds.EmitOnce(res, &ncmd.ResolvedPath{Path: ipfspath.Path(encoded)})
144 },
145 Encoders: cmds.EncoderMap{
146 cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, rp *ncmd.ResolvedPath) error {
core/commands/unixfs/ls.go
+2 -2
@@ -12,7 +12,7 @@ import (
12 cmds "github.com/ipfs/go-ipfs-cmds"
13 merkledag "github.com/ipfs/go-merkledag"
14 unixfs "github.com/ipfs/go-unixfs"
15 - iface "github.com/ipfs/interface-go-ipfs-core"
15 + path "github.com/ipfs/interface-go-ipfs-core/path"
16 )
17
18 type LsLink struct {
@@ -96,7 +96,7 @@ possible, please use 'ipfs ls' instead.
96 for _, p := range paths {
97 ctx := req.Context
98
99 - merkleNode, err := api.ResolveNode(ctx, iface.ParsePath(p))
99 + merkleNode, err := api.ResolveNode(ctx, path.ParsePath(p))
100 if err != nil {
101 return err
102 }
core/coreapi/block.go
+8 -7
@@ -14,12 +14,13 @@ import (
14 cid "github.com/ipfs/go-cid"
15 coreiface "github.com/ipfs/interface-go-ipfs-core"
16 caopts "github.com/ipfs/interface-go-ipfs-core/options"
17 + path "github.com/ipfs/interface-go-ipfs-core/path"
18 )
19
20 type BlockAPI CoreAPI
21
22 type BlockStat struct {
22 - path coreiface.ResolvedPath
23 + path path.ResolvedPath
24 size int
25 }
26
@@ -57,10 +58,10 @@ func (api *BlockAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.Bloc
58 api.pinning.PinWithMode(b.Cid(), pin.Recursive)
59 }
60
60 - return &BlockStat{path: coreiface.IpldPath(b.Cid()), size: len(data)}, nil
61 + return &BlockStat{path: path.IpldPath(b.Cid()), size: len(data)}, nil
62 }
63
63 -func (api *BlockAPI) Get(ctx context.Context, p coreiface.Path) (io.Reader, error) {
64 +func (api *BlockAPI) Get(ctx context.Context, p path.Path) (io.Reader, error) {
65 rp, err := api.core().ResolvePath(ctx, p)
66 if err != nil {
67 return nil, err
@@ -74,7 +75,7 @@ func (api *BlockAPI) Get(ctx context.Context, p coreiface.Path) (io.Reader, erro
75 return bytes.NewReader(b.RawData()), nil
76 }
77
77 -func (api *BlockAPI) Rm(ctx context.Context, p coreiface.Path, opts ...caopts.BlockRmOption) error {
78 +func (api *BlockAPI) Rm(ctx context.Context, p path.Path, opts ...caopts.BlockRmOption) error {
79 rp, err := api.core().ResolvePath(ctx, p)
80 if err != nil {
81 return err
@@ -112,7 +113,7 @@ func (api *BlockAPI) Rm(ctx context.Context, p coreiface.Path, opts ...caopts.Bl
113 }
114 }
115
115 -func (api *BlockAPI) Stat(ctx context.Context, p coreiface.Path) (coreiface.BlockStat, error) {
116 +func (api *BlockAPI) Stat(ctx context.Context, p path.Path) (coreiface.BlockStat, error) {
117 rp, err := api.core().ResolvePath(ctx, p)
118 if err != nil {
119 return nil, err
@@ -124,7 +125,7 @@ func (api *BlockAPI) Stat(ctx context.Context, p coreiface.Path) (coreiface.Bloc
125 }
126
127 return &BlockStat{
127 - path: coreiface.IpldPath(b.Cid()),
128 + path: path.IpldPath(b.Cid()),
129 size: len(b.RawData()),
130 }, nil
131 }
@@ -133,7 +134,7 @@ func (bs *BlockStat) Size() int {
134 return bs.size
135 }
136
136 -func (bs *BlockStat) Path() coreiface.ResolvedPath {
137 +func (bs *BlockStat) Path() path.ResolvedPath {
138 return bs.path
139 }
140
core/coreapi/dht.go
+3 -2
@@ -12,6 +12,7 @@ import (
12 dag "github.com/ipfs/go-merkledag"
13 coreiface "github.com/ipfs/interface-go-ipfs-core"
14 caopts "github.com/ipfs/interface-go-ipfs-core/options"
15 + path "github.com/ipfs/interface-go-ipfs-core/path"
16 peer "github.com/libp2p/go-libp2p-peer"
17 pstore "github.com/libp2p/go-libp2p-peerstore"
18 routing "github.com/libp2p/go-libp2p-routing"
@@ -33,7 +34,7 @@ func (api *DhtAPI) FindPeer(ctx context.Context, p peer.ID) (pstore.PeerInfo, er
34 return pi, nil
35 }
36
36 -func (api *DhtAPI) FindProviders(ctx context.Context, p coreiface.Path, opts ...caopts.DhtFindProvidersOption) (<-chan pstore.PeerInfo, error) {
37 +func (api *DhtAPI) FindProviders(ctx context.Context, p path.Path, opts ...caopts.DhtFindProvidersOption) (<-chan pstore.PeerInfo, error) {
38 settings, err := caopts.DhtFindProvidersOptions(opts...)
39 if err != nil {
40 return nil, err
@@ -58,7 +59,7 @@ func (api *DhtAPI) FindProviders(ctx context.Context, p coreiface.Path, opts ...
59 return pchan, nil
60 }
61
61 -func (api *DhtAPI) Provide(ctx context.Context, path coreiface.Path, opts ...caopts.DhtProvideOption) error {
62 +func (api *DhtAPI) Provide(ctx context.Context, path path.Path, opts ...caopts.DhtProvideOption) error {
63 settings, err := caopts.DhtProvideOptions(opts...)
64 if err != nil {
65 return err
core/coreapi/key.go
+3 -2
@@ -10,6 +10,7 @@ import (
10 ipfspath "github.com/ipfs/go-path"
11 coreiface "github.com/ipfs/interface-go-ipfs-core"
12 caopts "github.com/ipfs/interface-go-ipfs-core/options"
13 + path "github.com/ipfs/interface-go-ipfs-core/path"
14 crypto "github.com/libp2p/go-libp2p-crypto"
15 peer "github.com/libp2p/go-libp2p-peer"
16 )
@@ -27,8 +28,8 @@ func (k *key) Name() string {
28 }
29
30 // Path returns the path of the key.
30 -func (k *key) Path() coreiface.Path {
31 - return coreiface.ParsePath(ipfspath.Join([]string{"/ipns", k.peerID.Pretty()}))
31 +func (k *key) Path() path.Path {
32 + return path.ParsePath(ipfspath.Join([]string{"/ipns", k.peerID.Pretty()}))
33 }
34
35 // ID returns key PeerID
core/coreapi/name.go
+7 -6
@@ -12,6 +12,7 @@ import (
12 ipath "github.com/ipfs/go-path"
13 coreiface "github.com/ipfs/interface-go-ipfs-core"
14 caopts "github.com/ipfs/interface-go-ipfs-core/options"
15 + path "github.com/ipfs/interface-go-ipfs-core/path"
16 "github.com/libp2p/go-libp2p-crypto"
17 ci "github.com/libp2p/go-libp2p-crypto"
18 "github.com/libp2p/go-libp2p-peer"
@@ -21,7 +22,7 @@ type NameAPI CoreAPI
22
23 type ipnsEntry struct {
24 name string
24 - value coreiface.Path
25 + value path.Path
26 }
27
28 // Name returns the ipnsEntry name.
@@ -30,12 +31,12 @@ func (e *ipnsEntry) Name() string {
31 }
32
33 // Value returns the ipnsEntry value.
33 -func (e *ipnsEntry) Value() coreiface.Path {
34 +func (e *ipnsEntry) Value() path.Path {
35 return e.value
36 }
37
38 // Publish announces new IPNS name and returns the new IPNS entry.
38 -func (api *NameAPI) Publish(ctx context.Context, p coreiface.Path, opts ...caopts.NamePublishOption) (coreiface.IpnsEntry, error) {
39 +func (api *NameAPI) Publish(ctx context.Context, p path.Path, opts ...caopts.NamePublishOption) (coreiface.IpnsEntry, error) {
40 if err := api.checkPublishAllowed(); err != nil {
41 return nil, err
42 }
@@ -107,7 +108,7 @@ func (api *NameAPI) Search(ctx context.Context, name string, opts ...caopts.Name
108 defer close(out)
109 for res := range resolver.ResolveAsync(ctx, name, options.ResolveOpts...) {
110 select {
110 - case out <- coreiface.IpnsResult{Path: coreiface.ParsePath(res.Path.String()), Err: res.Err}:
111 + case out <- coreiface.IpnsResult{Path: path.ParsePath(res.Path.String()), Err: res.Err}:
112 case <-ctx.Done():
113 return
114 }
@@ -119,14 +120,14 @@ func (api *NameAPI) Search(ctx context.Context, name string, opts ...caopts.Name
120
121 // Resolve attempts to resolve the newest version of the specified name and
122 // returns its path.
122 -func (api *NameAPI) Resolve(ctx context.Context, name string, opts ...caopts.NameResolveOption) (coreiface.Path, error) {
123 +func (api *NameAPI) Resolve(ctx context.Context, name string, opts ...caopts.NameResolveOption) (path.Path, error) {
124 results, err := api.Search(ctx, name, opts...)
125 if err != nil {
126 return nil, err
127 }
128
129 err = coreiface.ErrResolveFailed
129 - var p coreiface.Path
130 + var p path.Path
131
132 for res := range results {
133 p, err = res.Path, res.Err
core/coreapi/object.go
+18 -17
@@ -20,6 +20,7 @@ import (
20 ft "github.com/ipfs/go-unixfs"
21 coreiface "github.com/ipfs/interface-go-ipfs-core"
22 caopts "github.com/ipfs/interface-go-ipfs-core/options"
23 + ipath "github.com/ipfs/interface-go-ipfs-core/path"
24 )
25
26 const inputLimit = 2 << 20
@@ -57,7 +58,7 @@ func (api *ObjectAPI) New(ctx context.Context, opts ...caopts.ObjectNewOption) (
58 return n, nil
59 }
60
60 -func (api *ObjectAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.ObjectPutOption) (coreiface.ResolvedPath, error) {
61 +func (api *ObjectAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.ObjectPutOption) (ipath.ResolvedPath, error) {
62 options, err := caopts.ObjectPutOptions(opts...)
63 if err != nil {
64 return nil, err
@@ -134,14 +135,14 @@ func (api *ObjectAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.Obj
135 }
136 }
137
137 - return coreiface.IpfsPath(dagnode.Cid()), nil
138 + return ipath.IpfsPath(dagnode.Cid()), nil
139 }
140
140 -func (api *ObjectAPI) Get(ctx context.Context, path coreiface.Path) (ipld.Node, error) {
141 +func (api *ObjectAPI) Get(ctx context.Context, path ipath.Path) (ipld.Node, error) {
142 return api.core().ResolveNode(ctx, path)
143 }
144
144 -func (api *ObjectAPI) Data(ctx context.Context, path coreiface.Path) (io.Reader, error) {
145 +func (api *ObjectAPI) Data(ctx context.Context, path ipath.Path) (io.Reader, error) {
146 nd, err := api.core().ResolveNode(ctx, path)
147 if err != nil {
148 return nil, err
@@ -155,7 +156,7 @@ func (api *ObjectAPI) Data(ctx context.Context, path coreiface.Path) (io.Reader,
156 return bytes.NewReader(pbnd.Data()), nil
157 }
158
158 -func (api *ObjectAPI) Links(ctx context.Context, path coreiface.Path) ([]*ipld.Link, error) {
159 +func (api *ObjectAPI) Links(ctx context.Context, path ipath.Path) ([]*ipld.Link, error) {
160 nd, err := api.core().ResolveNode(ctx, path)
161 if err != nil {
162 return nil, err
@@ -170,7 +171,7 @@ func (api *ObjectAPI) Links(ctx context.Context, path coreiface.Path) ([]*ipld.L
171 return out, nil
172 }
173
173 -func (api *ObjectAPI) Stat(ctx context.Context, path coreiface.Path) (*coreiface.ObjectStat, error) {
174 +func (api *ObjectAPI) Stat(ctx context.Context, path ipath.Path) (*coreiface.ObjectStat, error) {
175 nd, err := api.core().ResolveNode(ctx, path)
176 if err != nil {
177 return nil, err
@@ -193,7 +194,7 @@ func (api *ObjectAPI) Stat(ctx context.Context, path coreiface.Path) (*coreiface
194 return out, nil
195 }
196
196 -func (api *ObjectAPI) AddLink(ctx context.Context, base coreiface.Path, name string, child coreiface.Path, opts ...caopts.ObjectAddLinkOption) (coreiface.ResolvedPath, error) {
197 +func (api *ObjectAPI) AddLink(ctx context.Context, base ipath.Path, name string, child ipath.Path, opts ...caopts.ObjectAddLinkOption) (ipath.ResolvedPath, error) {
198 options, err := caopts.ObjectAddLinkOptions(opts...)
199 if err != nil {
200 return nil, err
@@ -231,10 +232,10 @@ func (api *ObjectAPI) AddLink(ctx context.Context, base coreiface.Path, name str
232 return nil, err
233 }
234
234 - return coreiface.IpfsPath(nnode.Cid()), nil
235 + return ipath.IpfsPath(nnode.Cid()), nil
236 }
237
237 -func (api *ObjectAPI) RmLink(ctx context.Context, base coreiface.Path, link string) (coreiface.ResolvedPath, error) {
238 +func (api *ObjectAPI) RmLink(ctx context.Context, base ipath.Path, link string) (ipath.ResolvedPath, error) {
239 baseNd, err := api.core().ResolveNode(ctx, base)
240 if err != nil {
241 return nil, err
@@ -257,18 +258,18 @@ func (api *ObjectAPI) RmLink(ctx context.Context, base coreiface.Path, link stri
258 return nil, err
259 }
260
260 - return coreiface.IpfsPath(nnode.Cid()), nil
261 + return ipath.IpfsPath(nnode.Cid()), nil
262 }
263
263 -func (api *ObjectAPI) AppendData(ctx context.Context, path coreiface.Path, r io.Reader) (coreiface.ResolvedPath, error) {
264 +func (api *ObjectAPI) AppendData(ctx context.Context, path ipath.Path, r io.Reader) (ipath.ResolvedPath, error) {
265 return api.patchData(ctx, path, r, true)
266 }
267
267 -func (api *ObjectAPI) SetData(ctx context.Context, path coreiface.Path, r io.Reader) (coreiface.ResolvedPath, error) {
268 +func (api *ObjectAPI) SetData(ctx context.Context, path ipath.Path, r io.Reader) (ipath.ResolvedPath, error) {
269 return api.patchData(ctx, path, r, false)
270 }
271
271 -func (api *ObjectAPI) patchData(ctx context.Context, path coreiface.Path, r io.Reader, appendData bool) (coreiface.ResolvedPath, error) {
272 +func (api *ObjectAPI) patchData(ctx context.Context, path ipath.Path, r io.Reader, appendData bool) (ipath.ResolvedPath, error) {
273 nd, err := api.core().ResolveNode(ctx, path)
274 if err != nil {
275 return nil, err
@@ -294,10 +295,10 @@ func (api *ObjectAPI) patchData(ctx context.Context, path coreiface.Path, r io.R
295 return nil, err
296 }
297
297 - return coreiface.IpfsPath(pbnd.Cid()), nil
298 + return ipath.IpfsPath(pbnd.Cid()), nil
299 }
300
300 -func (api *ObjectAPI) Diff(ctx context.Context, before coreiface.Path, after coreiface.Path) ([]coreiface.ObjectChange, error) {
301 +func (api *ObjectAPI) Diff(ctx context.Context, before ipath.Path, after ipath.Path) ([]coreiface.ObjectChange, error) {
302 beforeNd, err := api.core().ResolveNode(ctx, before)
303 if err != nil {
304 return nil, err
@@ -321,11 +322,11 @@ func (api *ObjectAPI) Diff(ctx context.Context, before coreiface.Path, after cor
322 }
323
324 if change.Before.Defined() {
324 - out[i].Before = coreiface.IpfsPath(change.Before)
325 + out[i].Before = ipath.IpfsPath(change.Before)
326 }
327
328 if change.After.Defined() {
328 - out[i].After = coreiface.IpfsPath(change.After)
329 + out[i].After = ipath.IpfsPath(change.After)
330 }
331 }
332
core/coreapi/path.go
+6 -5
@@ -13,11 +13,12 @@ import (
13 "github.com/ipfs/go-path/resolver"
14 uio "github.com/ipfs/go-unixfs/io"
15 coreiface "github.com/ipfs/interface-go-ipfs-core"
16 + path "github.com/ipfs/interface-go-ipfs-core/path"
17 )
18
19 // ResolveNode resolves the path `p` using Unixfs resolver, gets and returns the
20 // resolved Node.
20 -func (api *CoreAPI) ResolveNode(ctx context.Context, p coreiface.Path) (ipld.Node, error) {
21 +func (api *CoreAPI) ResolveNode(ctx context.Context, p path.Path) (ipld.Node, error) {
22 rp, err := api.ResolvePath(ctx, p)
23 if err != nil {
24 return nil, err
@@ -32,9 +33,9 @@ func (api *CoreAPI) ResolveNode(ctx context.Context, p coreiface.Path) (ipld.Nod
33
34 // ResolvePath resolves the path `p` using Unixfs resolver, returns the
35 // resolved path.
35 -func (api *CoreAPI) ResolvePath(ctx context.Context, p coreiface.Path) (coreiface.ResolvedPath, error) {
36 - if _, ok := p.(coreiface.ResolvedPath); ok {
37 - return p.(coreiface.ResolvedPath), nil
36 +func (api *CoreAPI) ResolvePath(ctx context.Context, p path.Path) (path.ResolvedPath, error) {
37 + if _, ok := p.(path.ResolvedPath); ok {
38 + return p.(path.ResolvedPath), nil
39 }
40 if err := p.IsValid(); err != nil {
41 return nil, err
@@ -74,5 +75,5 @@ func (api *CoreAPI) ResolvePath(ctx context.Context, p coreiface.Path) (coreifac
75 return nil, err
76 }
77
77 - return coreiface.NewResolvedPath(ipath, node, root, gopath.Join(rest...)), nil
78 + return path.NewResolvedPath(ipath, node, root, gopath.Join(rest...)), nil
79 }
core/coreapi/pin.go
+10 -9
@@ -10,11 +10,12 @@ import (
10 merkledag "github.com/ipfs/go-merkledag"
11 coreiface "github.com/ipfs/interface-go-ipfs-core"
12 caopts "github.com/ipfs/interface-go-ipfs-core/options"
13 + path "github.com/ipfs/interface-go-ipfs-core/path"
14 )
15
16 type PinAPI CoreAPI
17
17 -func (api *PinAPI) Add(ctx context.Context, p coreiface.Path, opts ...caopts.PinAddOption) error {
18 +func (api *PinAPI) Add(ctx context.Context, p path.Path, opts ...caopts.PinAddOption) error {
19 dagNode, err := api.core().ResolveNode(ctx, p)
20 if err != nil {
21 return fmt.Errorf("pin: %s", err)
@@ -55,7 +56,7 @@ func (api *PinAPI) Ls(ctx context.Context, opts ...caopts.PinLsOption) ([]coreif
56 }
57
58 // Rm pin rm api
58 -func (api *PinAPI) Rm(ctx context.Context, p coreiface.Path, opts ...caopts.PinRmOption) error {
59 +func (api *PinAPI) Rm(ctx context.Context, p path.Path, opts ...caopts.PinRmOption) error {
60 rp, err := api.core().ResolvePath(ctx, p)
61 if err != nil {
62 return err
@@ -73,7 +74,7 @@ func (api *PinAPI) Rm(ctx context.Context, p coreiface.Path, opts ...caopts.PinR
74 return api.pinning.Flush()
75 }
76
76 -func (api *PinAPI) Update(ctx context.Context, from coreiface.Path, to coreiface.Path, opts ...caopts.PinUpdateOption) error {
77 +func (api *PinAPI) Update(ctx context.Context, from path.Path, to path.Path, opts ...caopts.PinUpdateOption) error {
78 settings, err := caopts.PinUpdateOptions(opts...)
79 if err != nil {
80 return err
@@ -107,7 +108,7 @@ type pinStatus struct {
108
109 // BadNode is used in PinVerifyRes
110 type badNode struct {
110 - path coreiface.ResolvedPath
111 + path path.ResolvedPath
112 err error
113 }
114
@@ -119,7 +120,7 @@ func (s *pinStatus) BadNodes() []coreiface.BadPinNode {
120 return s.badNodes
121 }
122
122 -func (n *badNode) Path() coreiface.ResolvedPath {
123 +func (n *badNode) Path() path.ResolvedPath {
124 return n.path
125 }
126
@@ -143,7 +144,7 @@ func (api *PinAPI) Verify(ctx context.Context) (<-chan coreiface.PinStatus, erro
144 links, err := getLinks(ctx, root)
145 if err != nil {
146 status := &pinStatus{ok: false, cid: root}
146 - status.badNodes = []coreiface.BadPinNode{&badNode{path: coreiface.IpldPath(root), err: err}}
147 + status.badNodes = []coreiface.BadPinNode{&badNode{path: path.IpldPath(root), err: err}}
148 visited[root] = status
149 return status
150 }
@@ -174,10 +175,10 @@ func (api *PinAPI) Verify(ctx context.Context) (<-chan coreiface.PinStatus, erro
175
176 type pinInfo struct {
177 pinType string
177 - path coreiface.ResolvedPath
178 + path path.ResolvedPath
179 }
180
180 -func (p *pinInfo) Path() coreiface.ResolvedPath {
181 +func (p *pinInfo) Path() path.ResolvedPath {
182 return p.path
183 }
184
@@ -193,7 +194,7 @@ func (api *PinAPI) pinLsAll(typeStr string, ctx context.Context) ([]coreiface.Pi
194 for _, c := range keyList {
195 keys[c] = &pinInfo{
196 pinType: typeStr,
196 - path: coreiface.IpldPath(c),
197 + path: path.IpldPath(c),
198 }
199 }
200 }
core/coreapi/unixfs.go
+6 -5
@@ -22,14 +22,15 @@ import (
22 unixfile "github.com/ipfs/go-unixfs/file"
23 uio "github.com/ipfs/go-unixfs/io"
24 coreiface "github.com/ipfs/interface-go-ipfs-core"
25 - "github.com/ipfs/interface-go-ipfs-core/options"
25 + options "github.com/ipfs/interface-go-ipfs-core/options"
26 + path "github.com/ipfs/interface-go-ipfs-core/path"
27 )
28
29 type UnixfsAPI CoreAPI
30
31 // Add builds a merkledag node from a reader, adds it to the blockstore,
32 // and returns the key representing that node.
32 -func (api *UnixfsAPI) Add(ctx context.Context, files files.Node, opts ...options.UnixfsAddOption) (coreiface.ResolvedPath, error) {
33 +func (api *UnixfsAPI) Add(ctx context.Context, files files.Node, opts ...options.UnixfsAddOption) (path.ResolvedPath, error) {
34 settings, prefix, err := options.UnixfsAddOptions(opts...)
35 if err != nil {
36 return nil, err
@@ -130,10 +131,10 @@ func (api *UnixfsAPI) Add(ctx context.Context, files files.Node, opts ...options
131 return nil, err
132 }
133
133 - return coreiface.IpfsPath(nd.Cid()), nil
134 + return path.IpfsPath(nd.Cid()), nil
135 }
136
136 -func (api *UnixfsAPI) Get(ctx context.Context, p coreiface.Path) (files.Node, error) {
137 +func (api *UnixfsAPI) Get(ctx context.Context, p path.Path) (files.Node, error) {
138 ses := api.core().getSession(ctx)
139
140 nd, err := ses.ResolveNode(ctx, p)
@@ -146,7 +147,7 @@ func (api *UnixfsAPI) Get(ctx context.Context, p coreiface.Path) (files.Node, er
147
148 // Ls returns the contents of an IPFS or IPNS object(s) at path p, with the format:
149 // `<link base58 hash> <link size in bytes> <link name>`
149 -func (api *UnixfsAPI) Ls(ctx context.Context, p coreiface.Path, opts ...options.UnixfsLsOption) (<-chan coreiface.DirEntry, error) {
150 +func (api *UnixfsAPI) Ls(ctx context.Context, p path.Path, opts ...options.UnixfsLsOption) (<-chan coreiface.DirEntry, error) {
151 settings, err := options.UnixfsLsOptions(opts...)
152 if err != nil {
153 return nil, err
core/corehttp/gateway_handler.go
+3 -2
@@ -26,6 +26,7 @@ import (
26 ft "github.com/ipfs/go-unixfs"
27 "github.com/ipfs/go-unixfs/importer"
28 coreiface "github.com/ipfs/interface-go-ipfs-core"
29 + ipath "github.com/ipfs/interface-go-ipfs-core/path"
30 "github.com/libp2p/go-libp2p-routing"
31 "github.com/multiformats/go-multibase"
32 )
@@ -147,7 +148,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr
148 ipnsHostname = true
149 }
150
150 - parsedPath := coreiface.ParsePath(urlPath)
151 + parsedPath := ipath.ParsePath(urlPath)
152 if err := parsedPath.IsValid(); err != nil {
153 webError(w, "invalid ipfs path", err, http.StatusBadRequest)
154 return
@@ -246,7 +247,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr
247 return
248 }
249
249 - idx, err := i.api.Unixfs().Get(ctx, coreiface.Join(resolvedPath, "index.html"))
250 + idx, err := i.api.Unixfs().Get(ctx, ipath.Join(resolvedPath, "index.html"))
251 switch err.(type) {
252 case nil:
253 dirwithoutslash := urlPath[len(urlPath)-1] != '/'
core/corehttp/gateway_test.go
+3 -2
@@ -23,6 +23,7 @@ import (
23 path "github.com/ipfs/go-path"
24 iface "github.com/ipfs/interface-go-ipfs-core"
25 nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys"
26 + ipath "github.com/ipfs/interface-go-ipfs-core/path"
27 ci "github.com/libp2p/go-libp2p-crypto"
28 id "github.com/libp2p/go-libp2p/p2p/protocol/identify"
29 )
@@ -344,12 +345,12 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
345 t.Fatal(err)
346 }
347
347 - k2, err := api.ResolvePath(ctx, iface.Join(k, "foo? #<'"))
348 + k2, err := api.ResolvePath(ctx, ipath.Join(k, "foo? #<'"))
349 if err != nil {
350 t.Fatal(err)
351 }
352
352 - k3, err := api.ResolvePath(ctx, iface.Join(k, "foo? #<'/bar"))
353 + k3, err := api.ResolvePath(ctx, ipath.Join(k, "foo? #<'/bar"))
354 if err != nil {
355 t.Fatal(err)
356 }
core/coreunix/add.go
+2 -1
@@ -24,6 +24,7 @@ import (
24 ihelper "github.com/ipfs/go-unixfs/importer/helpers"
25 "github.com/ipfs/go-unixfs/importer/trickle"
26 coreiface "github.com/ipfs/interface-go-ipfs-core"
27 + "github.com/ipfs/interface-go-ipfs-core/path"
28 )
29
30 var log = logging.Logger("coreunix")
@@ -478,7 +479,7 @@ func getOutput(dagnode ipld.Node) (*coreiface.AddEvent, error) {
479 }
480
481 output := &coreiface.AddEvent{
481 - Path: coreiface.IpfsPath(c),
482 + Path: path.IpfsPath(c),
483 Size: strconv.FormatUint(s, 10),
484 }
485
fuse/readonly/ipfs_test.go
+2 -2
@@ -30,7 +30,7 @@ import (
30 dag "github.com/ipfs/go-merkledag"
31 importer "github.com/ipfs/go-unixfs/importer"
32 uio "github.com/ipfs/go-unixfs/io"
33 - iface "github.com/ipfs/interface-go-ipfs-core"
33 + ipath "github.com/ipfs/interface-go-ipfs-core/path"
34 ci "github.com/libp2p/go-testutil/ci"
35 )
36
@@ -184,7 +184,7 @@ func TestIpfsStressRead(t *testing.T) {
184 defer wg.Done()
185
186 for i := 0; i < 2000; i++ {
187 - item := iface.ParsePath(paths[rand.Intn(len(paths))])
187 + item := ipath.ParsePath(paths[rand.Intn(len(paths))])
188
189 relpath := strings.Replace(item.String(), item.Namespace(), "", 1)
190 fname := path.Join(mnt.Dir, relpath)