Skip to content
This repository was archived by the owner on Jun 19, 2023. It is now read-only.

Commit 21a7239

Browse files
committed
path: rename ParsePath and ResolvedPath
1 parent 5a83651 commit 21a7239

File tree

12 files changed

+33
-37
lines changed

12 files changed

+33
-37
lines changed

block.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type BlockStat interface {
1414
Size() int
1515

1616
// Path returns path to the block
17-
Path() path.ResolvedPath
17+
Path() path.Resolved
1818
}
1919

2020
// BlockAPI specifies the interface to the block layer

coreapi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type CoreAPI interface {
4444
PubSub() PubSubAPI
4545

4646
// ResolvePath resolves the path using Unixfs resolver
47-
ResolvePath(context.Context, path.Path) (path.ResolvedPath, error)
47+
ResolvePath(context.Context, path.Path) (path.Resolved, error)
4848

4949
// ResolveNode resolves the path (if not resolved already) using Unixfs
5050
// resolver, gets and returns the resolved Node

object.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ type ObjectChange struct {
5959

6060
// Before holds the link path before the change. Note that when a link is
6161
// added, this will be nil.
62-
Before path.ResolvedPath
62+
Before path.Resolved
6363

6464
// After holds the link path after the change. Note that when a link is
6565
// removed, this will be nil.
66-
After path.ResolvedPath
66+
After path.Resolved
6767
}
6868

6969
// ObjectAPI specifies the interface to MerkleDAG and contains useful utilities
@@ -73,7 +73,7 @@ type ObjectAPI interface {
7373
New(context.Context, ...options.ObjectNewOption) (ipld.Node, error)
7474

7575
// Put imports the data into merkledag
76-
Put(context.Context, io.Reader, ...options.ObjectPutOption) (path.ResolvedPath, error)
76+
Put(context.Context, io.Reader, ...options.ObjectPutOption) (path.Resolved, error)
7777

7878
// Get returns the node for the path
7979
Get(context.Context, path.Path) (ipld.Node, error)
@@ -90,16 +90,16 @@ type ObjectAPI interface {
9090
// AddLink adds a link under the specified path. child path can point to a
9191
// subdirectory within the patent which must be present (can be overridden
9292
// with WithCreate option).
93-
AddLink(ctx context.Context, base path.Path, name string, child path.Path, opts ...options.ObjectAddLinkOption) (path.ResolvedPath, error)
93+
AddLink(ctx context.Context, base path.Path, name string, child path.Path, opts ...options.ObjectAddLinkOption) (path.Resolved, error)
9494

9595
// RmLink removes a link from the node
96-
RmLink(ctx context.Context, base path.Path, link string) (path.ResolvedPath, error)
96+
RmLink(ctx context.Context, base path.Path, link string) (path.Resolved, error)
9797

9898
// AppendData appends data to the node
99-
AppendData(context.Context, path.Path, io.Reader) (path.ResolvedPath, error)
99+
AppendData(context.Context, path.Path, io.Reader) (path.Resolved, error)
100100

101101
// SetData sets the data contained in the node
102-
SetData(context.Context, path.Path, io.Reader) (path.ResolvedPath, error)
102+
SetData(context.Context, path.Path, io.Reader) (path.Resolved, error)
103103

104104
// Diff returns a set of changes needed to transform the first object into the
105105
// second.

path.go

Lines changed: 0 additions & 4 deletions
This file was deleted.

path/path.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ type Path interface {
3939
IsValid() error
4040
}
4141

42-
// ResolvedPath is a path which was resolved to the last resolvable node.
42+
// Resolved is a path which was resolved to the last resolvable node.
4343
// ResolvedPaths are guaranteed to return nil from `IsValid`
44-
type ResolvedPath interface {
44+
type Resolved interface {
4545
// Cid returns the CID of the node referenced by the path. Remainder of the
4646
// path is guaranteed to be within the node.
4747
//
@@ -120,7 +120,7 @@ func Join(base Path, a ...string) Path {
120120
}
121121

122122
// IpfsPath creates new /ipfs path from the provided CID
123-
func IpfsPath(c cid.Cid) ResolvedPath {
123+
func IpfsPath(c cid.Cid) Resolved {
124124
return &resolvedPath{
125125
path: path{"/ipfs/" + c.String()},
126126
cid: c,
@@ -130,7 +130,7 @@ func IpfsPath(c cid.Cid) ResolvedPath {
130130
}
131131

132132
// IpldPath creates new /ipld path from the provided CID
133-
func IpldPath(c cid.Cid) ResolvedPath {
133+
func IpldPath(c cid.Cid) Resolved {
134134
return &resolvedPath{
135135
path: path{"/ipld/" + c.String()},
136136
cid: c,
@@ -139,19 +139,19 @@ func IpldPath(c cid.Cid) ResolvedPath {
139139
}
140140
}
141141

142-
// ParsePath parses string path to a Path
143-
func ParsePath(p string) Path {
142+
// New parses string path to a Path
143+
func New(p string) Path {
144144
if pp, err := ipfspath.ParsePath(p); err == nil {
145145
p = pp.String()
146146
}
147147

148148
return &path{path: p}
149149
}
150150

151-
// NewResolvedPath creates new ResolvedPath. This function performs no checks
151+
// NewResolvedPath creates new Resolved path. This function performs no checks
152152
// and is intended to be used by resolver implementations. Incorrect inputs may
153153
// cause panics. Handle with care.
154-
func NewResolvedPath(ipath ipfspath.Path, c cid.Cid, root cid.Cid, remainder string) ResolvedPath {
154+
func NewResolvedPath(ipath ipfspath.Path, c cid.Cid, root cid.Cid, remainder string) Resolved {
155155
return &resolvedPath{
156156
path: path{ipath.String()},
157157
cid: c,

pin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
// Pin holds information about pinned resource
1111
type Pin interface {
1212
// Path to the pinned object
13-
Path() path.ResolvedPath
13+
Path() path.Resolved
1414

1515
// Type of the pin
1616
Type() string
@@ -28,7 +28,7 @@ type PinStatus interface {
2828
// BadPinNode is a node that has been marked as bad by Pin.Verify
2929
type BadPinNode interface {
3030
// Path is the path of the node
31-
Path() path.ResolvedPath
31+
Path() path.Resolved
3232

3333
// Err is the reason why the node has been marked as bad
3434
Err() error

tests/block.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (tp *provider) TestBlockGet(t *testing.T) {
111111
t.Error("didn't get correct data back")
112112
}
113113

114-
p := path.ParsePath("/ipfs/" + res.Path().Cid().String())
114+
p := path.New("/ipfs/" + res.Path().Cid().String())
115115

116116
rp, err := api.ResolvePath(ctx, p)
117117
if err != nil {

tests/dag.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (tp *provider) TestDagPath(t *testing.T) {
114114
t.Fatal(err)
115115
}
116116

117-
p := path.ParsePath(gopath.Join(nd.Cid().String(), "lnk"))
117+
p := path.New(gopath.Join(nd.Cid().String(), "lnk"))
118118

119119
rp, err := api.ResolvePath(ctx, p)
120120
if err != nil {

tests/name.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func addTestObject(ctx context.Context, api coreiface.CoreAPI) (path.Path, error
3636
}
3737

3838
func appendPath(p path.Path, sub string) path.Path {
39-
return path.ParsePath(gopath.Join(p.String(), sub))
39+
return path.New(gopath.Join(p.String(), sub))
4040
}
4141

4242
func (tp *provider) TestPublishResolve(t *testing.T) {

tests/path.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (tp *provider) TestPathRemainder(t *testing.T) {
7575
t.Fatal(err)
7676
}
7777

78-
rp1, err := api.ResolvePath(ctx, path.ParsePath(nd.String()+"/foo/bar"))
78+
rp1, err := api.ResolvePath(ctx, path.New(nd.String()+"/foo/bar"))
7979
if err != nil {
8080
t.Fatal(err)
8181
}
@@ -106,7 +106,7 @@ func (tp *provider) TestEmptyPathRemainder(t *testing.T) {
106106
t.Fatal(err)
107107
}
108108

109-
rp1, err := api.ResolvePath(ctx, path.ParsePath(nd.Cid().String()))
109+
rp1, err := api.ResolvePath(ctx, path.New(nd.Cid().String()))
110110
if err != nil {
111111
t.Fatal(err)
112112
}
@@ -137,7 +137,7 @@ func (tp *provider) TestInvalidPathRemainder(t *testing.T) {
137137
t.Fatal(err)
138138
}
139139

140-
_, err = api.ResolvePath(ctx, path.ParsePath("/ipld/"+nd.Cid().String()+"/bar/baz"))
140+
_, err = api.ResolvePath(ctx, path.New("/ipld/"+nd.Cid().String()+"/bar/baz"))
141141
if err == nil || !strings.Contains(err.Error(), "no such link found") {
142142
t.Fatalf("unexpected error: %s", err)
143143
}
@@ -173,7 +173,7 @@ func (tp *provider) TestPathRoot(t *testing.T) {
173173
t.Fatal(err)
174174
}
175175

176-
rp, err := api.ResolvePath(ctx, path.ParsePath("/ipld/"+nd.Cid().String()+"/foo"))
176+
rp, err := api.ResolvePath(ctx, path.New("/ipld/"+nd.Cid().String()+"/foo"))
177177
if err != nil {
178178
t.Fatal(err)
179179
}
@@ -188,7 +188,7 @@ func (tp *provider) TestPathRoot(t *testing.T) {
188188
}
189189

190190
func (tp *provider) TestPathJoin(t *testing.T) {
191-
p1 := path.ParsePath("/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz")
191+
p1 := path.New("/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz")
192192

193193
if path.Join(p1, "foo").String() != "/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz/foo" {
194194
t.Error("unexpected path")

0 commit comments

Comments
 (0)