Unverified Commit 77861581 authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #22 from ipfs/feat/drop-path-err

path: drop error from ParsePath
parents 0d5ec37a 21a72398
......@@ -2,9 +2,10 @@ package iface
import (
"context"
path "github.com/ipfs/interface-go-ipfs-core/path"
"io"
options "github.com/ipfs/interface-go-ipfs-core/options"
"github.com/ipfs/interface-go-ipfs-core/options"
)
// BlockStat contains information about a block
......@@ -13,7 +14,7 @@ type BlockStat interface {
Size() int
// Path returns path to the block
Path() ResolvedPath
Path() path.Resolved
}
// BlockAPI specifies the interface to the block layer
......@@ -22,15 +23,15 @@ type BlockAPI interface {
Put(context.Context, io.Reader, ...options.BlockPutOption) (BlockStat, error)
// Get attempts to resolve the path and return a reader for data in the block
Get(context.Context, Path) (io.Reader, error)
Get(context.Context, path.Path) (io.Reader, error)
// Rm removes the block specified by the path from local blockstore.
// By default an error will be returned if the block can't be found locally.
//
// NOTE: If the specified block is pinned it won't be removed and no error
// will be returned
Rm(context.Context, Path, ...options.BlockRmOption) error
Rm(context.Context, path.Path, ...options.BlockRmOption) error
// Stat returns information on
Stat(context.Context, Path) (BlockStat, error)
Stat(context.Context, path.Path) (BlockStat, error)
}
......@@ -4,6 +4,7 @@ package iface
import (
"context"
path "github.com/ipfs/interface-go-ipfs-core/path"
"github.com/ipfs/interface-go-ipfs-core/options"
......@@ -43,11 +44,11 @@ type CoreAPI interface {
PubSub() PubSubAPI
// ResolvePath resolves the path using Unixfs resolver
ResolvePath(context.Context, Path) (ResolvedPath, error)
ResolvePath(context.Context, path.Path) (path.Resolved, error)
// ResolveNode resolves the path (if not resolved already) using Unixfs
// resolver, gets and returns the resolved Node
ResolveNode(context.Context, Path) (ipld.Node, error)
ResolveNode(context.Context, path.Path) (ipld.Node, error)
// WithOptions creates new instance of CoreAPI based on this instance with
// a set of options applied
......
......@@ -2,10 +2,11 @@ package iface
import (
"context"
path "github.com/ipfs/interface-go-ipfs-core/path"
"github.com/ipfs/interface-go-ipfs-core/options"
peer "github.com/libp2p/go-libp2p-peer"
"github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
)
......@@ -19,8 +20,8 @@ type DhtAPI interface {
// FindProviders finds peers in the DHT who can provide a specific value
// given a key.
FindProviders(context.Context, Path, ...options.DhtFindProvidersOption) (<-chan pstore.PeerInfo, error)
FindProviders(context.Context, path.Path, ...options.DhtFindProvidersOption) (<-chan pstore.PeerInfo, error)
// Provide announces to the network that you are providing given values
Provide(context.Context, Path, ...options.DhtProvideOption) error
Provide(context.Context, path.Path, ...options.DhtProvideOption) error
}
......@@ -2,8 +2,9 @@ package iface
import (
"context"
path "github.com/ipfs/interface-go-ipfs-core/path"
options "github.com/ipfs/interface-go-ipfs-core/options"
"github.com/ipfs/interface-go-ipfs-core/options"
"github.com/libp2p/go-libp2p-peer"
)
......@@ -14,7 +15,7 @@ type Key interface {
Name() string
// Path returns key path
Path() Path
Path() path.Path
// ID returns key PeerID
ID() peer.ID
......
......@@ -3,8 +3,9 @@ package iface
import (
"context"
"errors"
path "github.com/ipfs/interface-go-ipfs-core/path"
options "github.com/ipfs/interface-go-ipfs-core/options"
"github.com/ipfs/interface-go-ipfs-core/options"
)
var ErrResolveFailed = errors.New("could not resolve name")
......@@ -14,11 +15,11 @@ type IpnsEntry interface {
// Name returns IpnsEntry name
Name() string
// Value returns IpnsEntry value
Value() Path
Value() path.Path
}
type IpnsResult struct {
Path
path.Path
Err error
}
......@@ -32,10 +33,10 @@ type IpnsResult struct {
// You can use .Key API to list and generate more names and their respective keys.
type NameAPI interface {
// Publish announces new IPNS name
Publish(ctx context.Context, path Path, opts ...options.NamePublishOption) (IpnsEntry, error)
Publish(ctx context.Context, path path.Path, opts ...options.NamePublishOption) (IpnsEntry, error)
// Resolve attempts to resolve the newest version of the specified name
Resolve(ctx context.Context, name string, opts ...options.NameResolveOption) (Path, error)
Resolve(ctx context.Context, name string, opts ...options.NameResolveOption) (path.Path, error)
// Search is a version of Resolve which outputs paths as they are discovered,
// reducing the time to first entry
......
......@@ -2,11 +2,12 @@ package iface
import (
"context"
path "github.com/ipfs/interface-go-ipfs-core/path"
"io"
options "github.com/ipfs/interface-go-ipfs-core/options"
"github.com/ipfs/interface-go-ipfs-core/options"
cid "github.com/ipfs/go-cid"
"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
)
......@@ -58,11 +59,11 @@ type ObjectChange struct {
// Before holds the link path before the change. Note that when a link is
// added, this will be nil.
Before ResolvedPath
Before path.Resolved
// After holds the link path after the change. Note that when a link is
// removed, this will be nil.
After ResolvedPath
After path.Resolved
}
// ObjectAPI specifies the interface to MerkleDAG and contains useful utilities
......@@ -72,35 +73,35 @@ type ObjectAPI interface {
New(context.Context, ...options.ObjectNewOption) (ipld.Node, error)
// Put imports the data into merkledag
Put(context.Context, io.Reader, ...options.ObjectPutOption) (ResolvedPath, error)
Put(context.Context, io.Reader, ...options.ObjectPutOption) (path.Resolved, error)
// Get returns the node for the path
Get(context.Context, Path) (ipld.Node, error)
Get(context.Context, path.Path) (ipld.Node, error)
// Data returns reader for data of the node
Data(context.Context, Path) (io.Reader, error)
Data(context.Context, path.Path) (io.Reader, error)
// Links returns lint or links the node contains
Links(context.Context, Path) ([]*ipld.Link, error)
Links(context.Context, path.Path) ([]*ipld.Link, error)
// Stat returns information about the node
Stat(context.Context, Path) (*ObjectStat, error)
Stat(context.Context, path.Path) (*ObjectStat, error)
// AddLink adds a link under the specified path. child path can point to a
// subdirectory within the patent which must be present (can be overridden
// with WithCreate option).
AddLink(ctx context.Context, base Path, name string, child Path, opts ...options.ObjectAddLinkOption) (ResolvedPath, error)
AddLink(ctx context.Context, base path.Path, name string, child path.Path, opts ...options.ObjectAddLinkOption) (path.Resolved, error)
// RmLink removes a link from the node
RmLink(ctx context.Context, base Path, link string) (ResolvedPath, error)
RmLink(ctx context.Context, base path.Path, link string) (path.Resolved, error)
// AppendData appends data to the node
AppendData(context.Context, Path, io.Reader) (ResolvedPath, error)
AppendData(context.Context, path.Path, io.Reader) (path.Resolved, error)
// SetData sets the data contained in the node
SetData(context.Context, Path, io.Reader) (ResolvedPath, error)
SetData(context.Context, path.Path, io.Reader) (path.Resolved, error)
// Diff returns a set of changes needed to transform the first object into the
// second.
Diff(context.Context, Path, Path) ([]ObjectChange, error)
Diff(context.Context, path.Path, path.Path) ([]ObjectChange, error)
}
package iface
package path
import (
"github.com/ipfs/go-cid"
"strings"
cid "github.com/ipfs/go-cid"
ipfspath "github.com/ipfs/go-path"
)
//TODO: merge with ipfspath so we don't depend on it
// Path is a generic wrapper for paths used in the API. A path can be resolved
// to a CID using one of Resolve functions in the API.
//
......@@ -23,6 +23,9 @@ type Path interface {
// Namespace returns the first component of the path.
//
// For example path "/ipfs/QmHash", calling Namespace() will return "ipfs"
//
// Calling this method on invalid paths (IsValid() != nil) will result in
// empty string
Namespace() string
// Mutable returns false if the data pointed to by this path in guaranteed
......@@ -30,10 +33,15 @@ type Path interface {
//
// Note that resolved mutable path can be immutable.
Mutable() bool
// IsValid checks if this path is a valid ipfs Path, returning nil iff it is
// valid
IsValid() error
}
// ResolvedPath is a path which was resolved to the last resolvable node
type ResolvedPath interface {
// Resolved is a path which was resolved to the last resolvable node.
// ResolvedPaths are guaranteed to return nil from `IsValid`
type Resolved interface {
// Cid returns the CID of the node referenced by the path. Remainder of the
// path is guaranteed to be within the node.
//
......@@ -94,7 +102,7 @@ type ResolvedPath interface {
// path implements coreiface.Path
type path struct {
path ipfspath.Path
path string
}
// resolvedPath implements coreiface.resolvedPath
......@@ -107,14 +115,14 @@ type resolvedPath struct {
// Join appends provided segments to the base path
func Join(base Path, a ...string) Path {
s := ipfspath.Join(append([]string{base.String()}, a...))
return &path{path: ipfspath.FromString(s)}
s := strings.Join(append([]string{base.String()}, a...), "/")
return &path{path: s}
}
// IpfsPath creates new /ipfs path from the provided CID
func IpfsPath(c cid.Cid) ResolvedPath {
func IpfsPath(c cid.Cid) Resolved {
return &resolvedPath{
path: path{ipfspath.Path("/ipfs/" + c.String())},
path: path{"/ipfs/" + c.String()},
cid: c,
root: c,
remainder: "",
......@@ -122,31 +130,30 @@ func IpfsPath(c cid.Cid) ResolvedPath {
}
// IpldPath creates new /ipld path from the provided CID
func IpldPath(c cid.Cid) ResolvedPath {
func IpldPath(c cid.Cid) Resolved {
return &resolvedPath{
path: path{ipfspath.Path("/ipld/" + c.String())},
path: path{"/ipld/" + c.String()},
cid: c,
root: c,
remainder: "",
}
}
// ParsePath parses string path to a Path
func ParsePath(p string) (Path, error) {
pp, err := ipfspath.ParsePath(p)
if err != nil {
return nil, err
// New parses string path to a Path
func New(p string) Path {
if pp, err := ipfspath.ParsePath(p); err == nil {
p = pp.String()
}
return &path{path: pp}, nil
return &path{path: p}
}
// NewResolvedPath creates new ResolvedPath. This function performs no checks
// NewResolvedPath creates new Resolved path. This function performs no checks
// and is intended to be used by resolver implementations. Incorrect inputs may
// cause panics. Handle with care.
func NewResolvedPath(ipath ipfspath.Path, c cid.Cid, root cid.Cid, remainder string) ResolvedPath {
func NewResolvedPath(ipath ipfspath.Path, c cid.Cid, root cid.Cid, remainder string) Resolved {
return &resolvedPath{
path: path{ipath},
path: path{ipath.String()},
cid: c,
root: root,
remainder: remainder,
......@@ -154,21 +161,31 @@ func NewResolvedPath(ipath ipfspath.Path, c cid.Cid, root cid.Cid, remainder str
}
func (p *path) String() string {
return p.path.String()
return p.path
}
func (p *path) Namespace() string {
if len(p.path.Segments()) < 1 {
panic("path without namespace") //this shouldn't happen under any scenario
ip, err := ipfspath.ParsePath(p.path)
if err != nil {
return ""
}
if len(ip.Segments()) < 1 {
panic("path without namespace") // this shouldn't happen under any scenario
}
return p.path.Segments()[0]
return ip.Segments()[0]
}
func (p *path) Mutable() bool {
//TODO: MFS: check for /local
// TODO: MFS: check for /local
return p.Namespace() == "ipns"
}
func (p *path) IsValid() error {
_, err := ipfspath.ParsePath(p.path)
return err
}
func (p *resolvedPath) Cid() cid.Cid {
return p.cid
}
......
......@@ -2,14 +2,15 @@ package iface
import (
"context"
path "github.com/ipfs/interface-go-ipfs-core/path"
options "github.com/ipfs/interface-go-ipfs-core/options"
"github.com/ipfs/interface-go-ipfs-core/options"
)
// Pin holds information about pinned resource
type Pin interface {
// Path to the pinned object
Path() ResolvedPath
Path() path.Resolved
// Type of the pin
Type() string
......@@ -27,7 +28,7 @@ type PinStatus interface {
// BadPinNode is a node that has been marked as bad by Pin.Verify
type BadPinNode interface {
// Path is the path of the node
Path() ResolvedPath
Path() path.Resolved
// Err is the reason why the node has been marked as bad
Err() error
......@@ -37,17 +38,17 @@ type BadPinNode interface {
type PinAPI interface {
// Add creates new pin, be default recursive - pinning the whole referenced
// tree
Add(context.Context, Path, ...options.PinAddOption) error
Add(context.Context, path.Path, ...options.PinAddOption) error
// Ls returns list of pinned objects on this node
Ls(context.Context, ...options.PinLsOption) ([]Pin, error)
// Rm removes pin for object specified by the path
Rm(context.Context, Path, ...options.PinRmOption) error
Rm(context.Context, path.Path, ...options.PinRmOption) error
// Update changes one pin to another, skipping checks for matching paths in
// the old tree
Update(ctx context.Context, from Path, to Path, opts ...options.PinUpdateOption) error
Update(ctx context.Context, from path.Path, to path.Path, opts ...options.PinUpdateOption) error
// Verify verifies the integrity of pinned objects
Verify(context.Context) (<-chan PinStatus, error)
......
......@@ -2,6 +2,7 @@ package tests
import (
"context"
"github.com/ipfs/interface-go-ipfs-core/path"
"io/ioutil"
"strings"
"testing"
......@@ -110,10 +111,7 @@ func (tp *provider) TestBlockGet(t *testing.T) {
t.Error("didn't get correct data back")
}
p, err := coreiface.ParsePath("/ipfs/" + res.Path().Cid().String())
if err != nil {
t.Fatal(err)
}
p := path.New("/ipfs/" + res.Path().Cid().String())
rp, err := api.ResolvePath(ctx, p)
if err != nil {
......
......@@ -2,8 +2,9 @@ package tests
import (
"context"
path "github.com/ipfs/interface-go-ipfs-core/path"
"math"
"path"
gopath "path"
"strings"
"testing"
......@@ -113,10 +114,7 @@ func (tp *provider) TestDagPath(t *testing.T) {
t.Fatal(err)
}
p, err := coreiface.ParsePath(path.Join(nd.Cid().String(), "lnk"))
if err != nil {
t.Fatal(err)
}
p := path.New(gopath.Join(nd.Cid().String(), "lnk"))
rp, err := api.ResolvePath(ctx, p)
if err != nil {
......
......@@ -2,9 +2,10 @@ package tests
import (
"context"
path "github.com/ipfs/interface-go-ipfs-core/path"
"io"
"math/rand"
"path"
gopath "path"
"testing"
"time"
......@@ -30,22 +31,18 @@ func (tp *provider) TestName(t *testing.T) {
var rnd = rand.New(rand.NewSource(0x62796532303137))
func addTestObject(ctx context.Context, api coreiface.CoreAPI) (coreiface.Path, error) {
func addTestObject(ctx context.Context, api coreiface.CoreAPI) (path.Path, error) {
return api.Unixfs().Add(ctx, files.NewReaderFile(&io.LimitedReader{R: rnd, N: 4092}))
}
func appendPath(p coreiface.Path, sub string) coreiface.Path {
p, err := coreiface.ParsePath(path.Join(p.String(), sub))
if err != nil {
panic(err)
}
return p
func appendPath(p path.Path, sub string) path.Path {
return path.New(gopath.Join(p.String(), sub))
}
func (tp *provider) TestPublishResolve(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
init := func() (coreiface.CoreAPI, coreiface.Path) {
init := func() (coreiface.CoreAPI, path.Path) {
apis, err := tp.MakeAPISwarm(ctx, true, 5)
if err != nil {
t.Fatal(err)
......@@ -60,7 +57,6 @@ func (tp *provider) TestPublishResolve(t *testing.T) {
}
return api, p
}
run := func(t *testing.T, ropts []opt.NameResolveOption) {
t.Run("basic", func(t *testing.T) {
api, p := init()
......
......@@ -2,11 +2,11 @@ package tests
import (
"context"
"github.com/ipfs/interface-go-ipfs-core/path"
"math"
"strings"
"testing"
coreiface "github.com/ipfs/interface-go-ipfs-core"
"github.com/ipfs/interface-go-ipfs-core/options"
ipldcbor "github.com/ipfs/go-ipld-cbor"
......@@ -75,12 +75,7 @@ func (tp *provider) TestPathRemainder(t *testing.T) {
t.Fatal(err)
}
p1, err := coreiface.ParsePath(nd.String() + "/foo/bar")
if err != nil {
t.Fatal(err)
}
rp1, err := api.ResolvePath(ctx, p1)
rp1, err := api.ResolvePath(ctx, path.New(nd.String()+"/foo/bar"))
if err != nil {
t.Fatal(err)
}
......@@ -111,12 +106,7 @@ func (tp *provider) TestEmptyPathRemainder(t *testing.T) {
t.Fatal(err)
}
p1, err := coreiface.ParsePath(nd.Cid().String())
if err != nil {
t.Fatal(err)
}
rp1, err := api.ResolvePath(ctx, p1)
rp1, err := api.ResolvePath(ctx, path.New(nd.Cid().String()))
if err != nil {
t.Fatal(err)
}
......@@ -147,12 +137,7 @@ func (tp *provider) TestInvalidPathRemainder(t *testing.T) {
t.Fatal(err)
}
p1, err := coreiface.ParsePath("/ipld/" + nd.Cid().String() + "/bar/baz")
if err != nil {
t.Fatal(err)
}
_, err = api.ResolvePath(ctx, p1)
_, err = api.ResolvePath(ctx, path.New("/ipld/"+nd.Cid().String()+"/bar/baz"))
if err == nil || !strings.Contains(err.Error(), "no such link found") {
t.Fatalf("unexpected error: %s", err)
}
......@@ -188,12 +173,7 @@ func (tp *provider) TestPathRoot(t *testing.T) {
t.Fatal(err)
}
p1, err := coreiface.ParsePath("/ipld/" + nd.Cid().String() + "/foo")
if err != nil {
t.Fatal(err)
}
rp, err := api.ResolvePath(ctx, p1)
rp, err := api.ResolvePath(ctx, path.New("/ipld/"+nd.Cid().String()+"/foo"))
if err != nil {
t.Fatal(err)
}
......@@ -208,12 +188,9 @@ func (tp *provider) TestPathRoot(t *testing.T) {
}
func (tp *provider) TestPathJoin(t *testing.T) {
p1, err := coreiface.ParsePath("/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz")
if err != nil {
t.Fatal(err)
}
p1 := path.New("/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz")
if coreiface.Join(p1, "foo").String() != "/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz/foo" {
if path.Join(p1, "foo").String() != "/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz/foo" {
t.Error("unexpected path")
}
}
......@@ -2,6 +2,7 @@ package tests
import (
"context"
"github.com/ipfs/interface-go-ipfs-core/path"
"math"
"strings"
"testing"
......@@ -127,12 +128,12 @@ func (tp *provider) TestPinRecursive(t *testing.T) {
t.Fatal(err)
}
err = api.Pin().Add(ctx, iface.IpldPath(nd2.Cid()))
err = api.Pin().Add(ctx, path.IpldPath(nd2.Cid()))
if err != nil {
t.Fatal(err)
}
err = api.Pin().Add(ctx, iface.IpldPath(nd3.Cid()), opt.Pin.Recursive(false))
err = api.Pin().Add(ctx, path.IpldPath(nd3.Cid()), opt.Pin.Recursive(false))
if err != nil {
t.Fatal(err)
}
......@@ -155,8 +156,8 @@ func (tp *provider) TestPinRecursive(t *testing.T) {
t.Errorf("unexpected pin list len: %d", len(list))
}
if list[0].Path().String() != iface.IpldPath(nd3.Cid()).String() {
t.Errorf("unexpected path, %s != %s", list[0].Path().String(), iface.IpfsPath(nd2.Cid()).String())
if list[0].Path().String() != path.IpldPath(nd3.Cid()).String() {
t.Errorf("unexpected path, %s != %s", list[0].Path().String(), path.IpfsPath(nd2.Cid()).String())
}
list, err = api.Pin().Ls(ctx, opt.Pin.Type.Recursive())
......@@ -168,8 +169,8 @@ func (tp *provider) TestPinRecursive(t *testing.T) {
t.Errorf("unexpected pin list len: %d", len(list))
}
if list[0].Path().String() != iface.IpldPath(nd2.Cid()).String() {
t.Errorf("unexpected path, %s != %s", list[0].Path().String(), iface.IpldPath(nd3.Cid()).String())
if list[0].Path().String() != path.IpldPath(nd2.Cid()).String() {
t.Errorf("unexpected path, %s != %s", list[0].Path().String(), path.IpldPath(nd3.Cid()).String())
}
list, err = api.Pin().Ls(ctx, opt.Pin.Type.Indirect())
......
......@@ -5,6 +5,7 @@ import (
"context"
"encoding/hex"
"fmt"
"github.com/ipfs/interface-go-ipfs-core/path"
"io"
"io/ioutil"
"math"
......@@ -101,12 +102,12 @@ func (tp *provider) TestAdd(t *testing.T) {
t.Fatal(err)
}
p := func(h string) coreiface.ResolvedPath {
p := func(h string) path.Resolved {
c, err := cid.Parse(h)
if err != nil {
t.Fatal(err)
}
return coreiface.IpfsPath(c)
return path.IpfsPath(c)
}
rf, err := ioutil.TempFile(os.TempDir(), "unixfs-add-real")
......@@ -592,10 +593,7 @@ func (tp *provider) TestGetEmptyFile(t *testing.T) {
t.Fatal(err)
}
emptyFilePath, err := coreiface.ParsePath(emptyFile)
if err != nil {
t.Fatal(err)
}
emptyFilePath := path.New(emptyFile)
r, err := api.Unixfs().Get(ctx, emptyFilePath)
if err != nil {
......@@ -624,18 +622,18 @@ func (tp *provider) TestGetDir(t *testing.T) {
if err != nil {
t.Fatal(err)
}
p := coreiface.IpfsPath(edir.Cid())
p := path.IpfsPath(edir.Cid())
emptyDir, err := api.Object().New(ctx, options.Object.Type("unixfs-dir"))
if err != nil {
t.Fatal(err)
}
if p.String() != coreiface.IpfsPath(emptyDir.Cid()).String() {
if p.String() != path.IpfsPath(emptyDir.Cid()).String() {
t.Fatalf("expected path %s, got: %s", emptyDir.Cid(), p.String())
}
r, err := api.Unixfs().Get(ctx, coreiface.IpfsPath(emptyDir.Cid()))
r, err := api.Unixfs().Get(ctx, path.IpfsPath(emptyDir.Cid()))
if err != nil {
t.Fatal(err)
}
......@@ -659,7 +657,7 @@ func (tp *provider) TestGetNonUnixfs(t *testing.T) {
t.Fatal(err)
}
_, err = api.Unixfs().Get(ctx, coreiface.IpfsPath(nd.Cid()))
_, err = api.Unixfs().Get(ctx, path.IpfsPath(nd.Cid()))
if !strings.Contains(err.Error(), "proto: required field") {
t.Fatalf("expected protobuf error, got: %s", err)
}
......@@ -785,7 +783,7 @@ func (tp *provider) TestLsEmptyDir(t *testing.T) {
t.Fatal(err)
}
links, err := api.Unixfs().Ls(ctx, coreiface.IpfsPath(emptyDir.Cid()))
links, err := api.Unixfs().Ls(ctx, path.IpfsPath(emptyDir.Cid()))
if err != nil {
t.Fatal(err)
}
......@@ -814,7 +812,7 @@ func (tp *provider) TestLsNonUnixfs(t *testing.T) {
t.Fatal(err)
}
links, err := api.Unixfs().Ls(ctx, coreiface.IpfsPath(nd.Cid()))
links, err := api.Unixfs().Ls(ctx, path.IpfsPath(nd.Cid()))
if err != nil {
t.Fatal(err)
}
......
......@@ -3,16 +3,17 @@ package iface
import (
"context"
"github.com/ipfs/interface-go-ipfs-core/options"
path "github.com/ipfs/interface-go-ipfs-core/path"
cid "github.com/ipfs/go-cid"
files "github.com/ipfs/go-ipfs-files"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-ipfs-files"
)
type AddEvent struct {
Name string
Path ResolvedPath `json:",omitempty"`
Bytes int64 `json:",omitempty"`
Size string `json:",omitempty"`
Path path.Resolved `json:",omitempty"`
Bytes int64 `json:",omitempty"`
Size string `json:",omitempty"`
}
// FileType is an enum of possible UnixFS file types.
......@@ -64,15 +65,15 @@ type UnixfsAPI interface {
// Add imports the data from the reader into merkledag file
//
// TODO: a long useful comment on how to use this for many different scenarios
Add(context.Context, files.Node, ...options.UnixfsAddOption) (ResolvedPath, error)
Add(context.Context, files.Node, ...options.UnixfsAddOption) (path.Resolved, error)
// Get returns a read-only handle to a file tree referenced by a path
//
// Note that some implementations of this API may apply the specified context
// to operations performed on the returned file
Get(context.Context, Path) (files.Node, error)
Get(context.Context, path.Path) (files.Node, error)
// Ls returns the list of links in a directory. Links aren't guaranteed to be
// returned in order
Ls(context.Context, Path, ...options.UnixfsLsOption) (<-chan DirEntry, error)
Ls(context.Context, path.Path, ...options.UnixfsLsOption) (<-chan DirEntry, error)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment