mirror of
https://github.com/ipfs/kubo.git
synced 2025-05-17 15:06:47 +08:00
feat: path consolidation (#10063)
This commit is contained in:
@ -12,8 +12,8 @@ import (
|
||||
"time"
|
||||
|
||||
iface "github.com/ipfs/boxo/coreiface"
|
||||
"github.com/ipfs/boxo/coreiface/path"
|
||||
"github.com/ipfs/boxo/coreiface/tests"
|
||||
"github.com/ipfs/boxo/path"
|
||||
"github.com/ipfs/kubo/test/cli/harness"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
"go.uber.org/multierr"
|
||||
@ -70,7 +70,11 @@ func (np NodeProvider) MakeAPISwarm(t *testing.T, ctx context.Context, fullIdent
|
||||
apis[i] = api
|
||||
|
||||
// empty node is pinned even with --empty-repo, we don't want that
|
||||
emptyNode := path.New("/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn")
|
||||
emptyNode, err := path.NewPath("/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := api.Pin().Rm(ctx, emptyNode); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -126,7 +130,11 @@ func Test_NewURLApiWithClient_With_Headers(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
api.Headers.Set(headerToTest, expectedHeaderValue)
|
||||
if err := api.Pin().Rm(context.Background(), path.New("/ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv")); err != nil {
|
||||
p, err := path.NewPath("/ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := api.Pin().Rm(context.Background(), p); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,9 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/ipfs/boxo/coreiface/path"
|
||||
"github.com/ipfs/boxo/files"
|
||||
unixfs "github.com/ipfs/boxo/ipld/unixfs"
|
||||
"github.com/ipfs/boxo/path"
|
||||
"github.com/ipfs/go-cid"
|
||||
)
|
||||
|
||||
@ -17,7 +17,7 @@ const forwardSeekLimit = 1 << 14 // 16k
|
||||
func (api *UnixfsAPI) Get(ctx context.Context, p path.Path) (files.Node, error) {
|
||||
if p.Mutable() { // use resolved path in case we are dealing with IPNS / MFS
|
||||
var err error
|
||||
p, err = api.core().ResolvePath(ctx, p)
|
||||
p, _, err = api.core().ResolvePath(ctx, p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -195,13 +195,13 @@ func (it *apiIter) Next() bool {
|
||||
|
||||
switch it.cur.Type {
|
||||
case unixfs.THAMTShard, unixfs.TMetadata, unixfs.TDirectory:
|
||||
it.curFile, err = it.core.getDir(it.ctx, path.IpfsPath(c), int64(it.cur.Size))
|
||||
it.curFile, err = it.core.getDir(it.ctx, path.FromCid(c), int64(it.cur.Size))
|
||||
if err != nil {
|
||||
it.err = err
|
||||
return false
|
||||
}
|
||||
case unixfs.TFile:
|
||||
it.curFile, err = it.core.getFile(it.ctx, path.IpfsPath(c), int64(it.cur.Size))
|
||||
it.curFile, err = it.core.getFile(it.ctx, path.FromCid(c), int64(it.cur.Size))
|
||||
if err != nil {
|
||||
it.err = err
|
||||
return false
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
|
||||
iface "github.com/ipfs/boxo/coreiface"
|
||||
caopts "github.com/ipfs/boxo/coreiface/options"
|
||||
"github.com/ipfs/boxo/coreiface/path"
|
||||
"github.com/ipfs/boxo/path"
|
||||
"github.com/ipfs/go-cid"
|
||||
mc "github.com/multiformats/go-multicodec"
|
||||
mh "github.com/multiformats/go-multihash"
|
||||
@ -27,8 +27,8 @@ func (s *blockStat) Size() int {
|
||||
return s.BSize
|
||||
}
|
||||
|
||||
func (s *blockStat) Path() path.Resolved {
|
||||
return path.IpldPath(s.cid)
|
||||
func (s *blockStat) Path() path.ImmutablePath {
|
||||
return path.FromCid(s.cid)
|
||||
}
|
||||
|
||||
func (api *BlockAPI) Put(ctx context.Context, r io.Reader, opts ...caopts.BlockPutOption) (iface.BlockStat, error) {
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
"io"
|
||||
|
||||
"github.com/ipfs/boxo/coreiface/options"
|
||||
"github.com/ipfs/boxo/coreiface/path"
|
||||
"github.com/ipfs/go-block-format"
|
||||
"github.com/ipfs/boxo/path"
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
"github.com/ipfs/go-cid"
|
||||
format "github.com/ipfs/go-ipld-format"
|
||||
multicodec "github.com/multiformats/go-multicodec"
|
||||
@ -21,7 +21,7 @@ type (
|
||||
)
|
||||
|
||||
func (api *HttpDagServ) Get(ctx context.Context, c cid.Cid) (format.Node, error) {
|
||||
r, err := api.core().Block().Get(ctx, path.IpldPath(c))
|
||||
r, err := api.core().Block().Get(ctx, path.FromCid(c))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -79,8 +79,8 @@ func (api *httpNodeAdder) add(ctx context.Context, nd format.Node, pin bool) err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !stat.Path().Cid().Equals(c) {
|
||||
return fmt.Errorf("cids didn't match - local %s, remote %s", c.String(), stat.Path().Cid().String())
|
||||
if !stat.Path().RootCid().Equals(c) {
|
||||
return fmt.Errorf("cids didn't match - local %s, remote %s", c.String(), stat.Path().RootCid().String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -116,7 +116,7 @@ func (api *HttpDagServ) Pinning() format.NodeAdder {
|
||||
}
|
||||
|
||||
func (api *HttpDagServ) Remove(ctx context.Context, c cid.Cid) error {
|
||||
return api.core().Block().Rm(ctx, path.IpldPath(c)) // TODO: should we force rm?
|
||||
return api.core().Block().Rm(ctx, path.FromCid(c)) // TODO: should we force rm?
|
||||
}
|
||||
|
||||
func (api *HttpDagServ) RemoveMany(ctx context.Context, cids []cid.Cid) error {
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
|
||||
caopts "github.com/ipfs/boxo/coreiface/options"
|
||||
"github.com/ipfs/boxo/coreiface/path"
|
||||
"github.com/ipfs/boxo/path"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/routing"
|
||||
)
|
||||
@ -42,12 +42,12 @@ func (api *DhtAPI) FindProviders(ctx context.Context, p path.Path, opts ...caopt
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rp, err := api.core().ResolvePath(ctx, p)
|
||||
rp, _, err := api.core().ResolvePath(ctx, p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := api.core().Request("dht/findprovs", rp.Cid().String()).
|
||||
resp, err := api.core().Request("dht/findprovs", rp.RootCid().String()).
|
||||
Option("num-providers", options.NumProviders).
|
||||
Send(ctx)
|
||||
if err != nil {
|
||||
@ -98,12 +98,12 @@ func (api *DhtAPI) Provide(ctx context.Context, p path.Path, opts ...caopts.DhtP
|
||||
return err
|
||||
}
|
||||
|
||||
rp, err := api.core().ResolvePath(ctx, p)
|
||||
rp, _, err := api.core().ResolvePath(ctx, p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return api.core().Request("dht/provide", rp.Cid().String()).
|
||||
return api.core().Request("dht/provide", rp.RootCid().String()).
|
||||
Option("recursive", options.Recursive).
|
||||
Exec(ctx, nil)
|
||||
}
|
||||
|
@ -6,31 +6,50 @@ import (
|
||||
|
||||
iface "github.com/ipfs/boxo/coreiface"
|
||||
caopts "github.com/ipfs/boxo/coreiface/options"
|
||||
"github.com/ipfs/boxo/coreiface/path"
|
||||
"github.com/ipfs/boxo/ipns"
|
||||
"github.com/ipfs/boxo/path"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
)
|
||||
|
||||
type KeyAPI HttpApi
|
||||
|
||||
type keyOutput struct {
|
||||
JName string `json:"Name"`
|
||||
Id string
|
||||
|
||||
pid peer.ID
|
||||
type key struct {
|
||||
name string
|
||||
pid peer.ID
|
||||
path path.Path
|
||||
}
|
||||
|
||||
func (k *keyOutput) Name() string {
|
||||
return k.JName
|
||||
func newKey(name, pidStr string) (*key, error) {
|
||||
pid, err := peer.Decode(pidStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
path, err := path.NewPath("/ipns/" + ipns.NameFromPeer(pid).String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &key{name: name, pid: pid, path: path}, nil
|
||||
}
|
||||
|
||||
func (k *keyOutput) Path() path.Path {
|
||||
return path.New("/ipns/" + k.Id)
|
||||
func (k *key) Name() string {
|
||||
return k.name
|
||||
}
|
||||
|
||||
func (k *keyOutput) ID() peer.ID {
|
||||
func (k *key) Path() path.Path {
|
||||
return k.path
|
||||
}
|
||||
|
||||
func (k *key) ID() peer.ID {
|
||||
return k.pid
|
||||
}
|
||||
|
||||
type keyOutput struct {
|
||||
Name string
|
||||
Id string
|
||||
}
|
||||
|
||||
func (api *KeyAPI) Generate(ctx context.Context, name string, opts ...caopts.KeyGenerateOption) (iface.Key, error) {
|
||||
options, err := caopts.KeyGenerateOptions(opts...)
|
||||
if err != nil {
|
||||
@ -45,8 +64,8 @@ func (api *KeyAPI) Generate(ctx context.Context, name string, opts ...caopts.Key
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.pid, err = peer.Decode(out.Id)
|
||||
return &out, err
|
||||
|
||||
return newKey(out.Name, out.Id)
|
||||
}
|
||||
|
||||
func (api *KeyAPI) Rename(ctx context.Context, oldName string, newName string, opts ...caopts.KeyRenameOption) (iface.Key, bool, error) {
|
||||
@ -68,25 +87,29 @@ func (api *KeyAPI) Rename(ctx context.Context, oldName string, newName string, o
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
id := &keyOutput{JName: out.Now, Id: out.Id}
|
||||
id.pid, err = peer.Decode(id.Id)
|
||||
return id, out.Overwrite, err
|
||||
key, err := newKey(out.Now, out.Id)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
return key, out.Overwrite, err
|
||||
}
|
||||
|
||||
func (api *KeyAPI) List(ctx context.Context) ([]iface.Key, error) {
|
||||
var out struct{ Keys []*keyOutput }
|
||||
var out struct {
|
||||
Keys []keyOutput
|
||||
}
|
||||
if err := api.core().Request("key/list").Exec(ctx, &out); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res := make([]iface.Key, len(out.Keys))
|
||||
for i, k := range out.Keys {
|
||||
var err error
|
||||
k.pid, err = peer.Decode(k.Id)
|
||||
key, err := newKey(k.Name, k.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res[i] = k
|
||||
res[i] = key
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@ -98,14 +121,13 @@ func (api *KeyAPI) Self(ctx context.Context) (iface.Key, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var err error
|
||||
out := keyOutput{JName: "self", Id: id.ID}
|
||||
out.pid, err = peer.Decode(out.Id)
|
||||
return &out, err
|
||||
return newKey("self", id.ID)
|
||||
}
|
||||
|
||||
func (api *KeyAPI) Remove(ctx context.Context, name string) (iface.Key, error) {
|
||||
var out struct{ Keys []keyOutput }
|
||||
var out struct {
|
||||
Keys []keyOutput
|
||||
}
|
||||
if err := api.core().Request("key/rm", name).Exec(ctx, &out); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -113,9 +135,7 @@ func (api *KeyAPI) Remove(ctx context.Context, name string) (iface.Key, error) {
|
||||
return nil, errors.New("got unexpected number of keys back")
|
||||
}
|
||||
|
||||
var err error
|
||||
out.Keys[0].pid, err = peer.Decode(out.Keys[0].Id)
|
||||
return &out.Keys[0], err
|
||||
return newKey(out.Keys[0].Name, out.Keys[0].Id)
|
||||
}
|
||||
|
||||
func (api *KeyAPI) core() *HttpApi {
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
iface "github.com/ipfs/boxo/coreiface"
|
||||
caopts "github.com/ipfs/boxo/coreiface/options"
|
||||
nsopts "github.com/ipfs/boxo/coreiface/options/namesys"
|
||||
"github.com/ipfs/boxo/coreiface/path"
|
||||
"github.com/ipfs/boxo/ipns"
|
||||
"github.com/ipfs/boxo/path"
|
||||
)
|
||||
|
||||
type NameAPI HttpApi
|
||||
@ -84,7 +84,11 @@ func (api *NameAPI) Search(ctx context.Context, name string, opts ...caopts.Name
|
||||
}
|
||||
var ires iface.IpnsResult
|
||||
if err == nil {
|
||||
ires.Path = path.New(out.Path)
|
||||
p, err := path.NewPath(out.Path)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ires.Path = p
|
||||
}
|
||||
|
||||
select {
|
||||
@ -122,7 +126,7 @@ func (api *NameAPI) Resolve(ctx context.Context, name string, opts ...caopts.Nam
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return path.New(out.Path), nil
|
||||
return path.NewPath(out.Path)
|
||||
}
|
||||
|
||||
func (api *NameAPI) core() *HttpApi {
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
|
||||
iface "github.com/ipfs/boxo/coreiface"
|
||||
caopts "github.com/ipfs/boxo/coreiface/options"
|
||||
"github.com/ipfs/boxo/coreiface/path"
|
||||
"github.com/ipfs/boxo/ipld/merkledag"
|
||||
ft "github.com/ipfs/boxo/ipld/unixfs"
|
||||
"github.com/ipfs/boxo/path"
|
||||
"github.com/ipfs/go-cid"
|
||||
ipld "github.com/ipfs/go-ipld-format"
|
||||
)
|
||||
@ -40,7 +40,7 @@ func (api *ObjectAPI) New(ctx context.Context, opts ...caopts.ObjectNewOption) (
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func (api *ObjectAPI) Put(ctx context.Context, r io.Reader, opts ...caopts.ObjectPutOption) (path.Resolved, error) {
|
||||
func (api *ObjectAPI) Put(ctx context.Context, r io.Reader, opts ...caopts.ObjectPutOption) (path.ImmutablePath, error) {
|
||||
options, err := caopts.ObjectPutOptions(opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -62,7 +62,7 @@ func (api *ObjectAPI) Put(ctx context.Context, r io.Reader, opts ...caopts.Objec
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return path.IpfsPath(c), nil
|
||||
return path.FromCid(c), nil
|
||||
}
|
||||
|
||||
func (api *ObjectAPI) Get(ctx context.Context, p path.Path) (ipld.Node, error) {
|
||||
@ -153,7 +153,7 @@ func (api *ObjectAPI) Stat(ctx context.Context, p path.Path) (*iface.ObjectStat,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (api *ObjectAPI) AddLink(ctx context.Context, base path.Path, name string, child path.Path, opts ...caopts.ObjectAddLinkOption) (path.Resolved, error) {
|
||||
func (api *ObjectAPI) AddLink(ctx context.Context, base path.Path, name string, child path.Path, opts ...caopts.ObjectAddLinkOption) (path.ImmutablePath, error) {
|
||||
options, err := caopts.ObjectAddLinkOptions(opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -172,10 +172,10 @@ func (api *ObjectAPI) AddLink(ctx context.Context, base path.Path, name string,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return path.IpfsPath(c), nil
|
||||
return path.FromCid(c), nil
|
||||
}
|
||||
|
||||
func (api *ObjectAPI) RmLink(ctx context.Context, base path.Path, link string) (path.Resolved, error) {
|
||||
func (api *ObjectAPI) RmLink(ctx context.Context, base path.Path, link string) (path.ImmutablePath, error) {
|
||||
var out objectOut
|
||||
err := api.core().Request("object/patch/rm-link", base.String(), link).
|
||||
Exec(ctx, &out)
|
||||
@ -188,10 +188,10 @@ func (api *ObjectAPI) RmLink(ctx context.Context, base path.Path, link string) (
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return path.IpfsPath(c), nil
|
||||
return path.FromCid(c), nil
|
||||
}
|
||||
|
||||
func (api *ObjectAPI) AppendData(ctx context.Context, p path.Path, r io.Reader) (path.Resolved, error) {
|
||||
func (api *ObjectAPI) AppendData(ctx context.Context, p path.Path, r io.Reader) (path.ImmutablePath, error) {
|
||||
var out objectOut
|
||||
err := api.core().Request("object/patch/append-data", p.String()).
|
||||
FileBody(r).
|
||||
@ -205,10 +205,10 @@ func (api *ObjectAPI) AppendData(ctx context.Context, p path.Path, r io.Reader)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return path.IpfsPath(c), nil
|
||||
return path.FromCid(c), nil
|
||||
}
|
||||
|
||||
func (api *ObjectAPI) SetData(ctx context.Context, p path.Path, r io.Reader) (path.Resolved, error) {
|
||||
func (api *ObjectAPI) SetData(ctx context.Context, p path.Path, r io.Reader) (path.ImmutablePath, error) {
|
||||
var out objectOut
|
||||
err := api.core().Request("object/patch/set-data", p.String()).
|
||||
FileBody(r).
|
||||
@ -222,7 +222,7 @@ func (api *ObjectAPI) SetData(ctx context.Context, p path.Path, r io.Reader) (pa
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return path.IpfsPath(c), nil
|
||||
return path.FromCid(c), nil
|
||||
}
|
||||
|
||||
type change struct {
|
||||
@ -246,10 +246,10 @@ func (api *ObjectAPI) Diff(ctx context.Context, a path.Path, b path.Path) ([]ifa
|
||||
Path: ch.Path,
|
||||
}
|
||||
if ch.Before != cid.Undef {
|
||||
res[i].Before = path.IpfsPath(ch.Before)
|
||||
res[i].Before = path.FromCid(ch.Before)
|
||||
}
|
||||
if ch.After != cid.Undef {
|
||||
res[i].After = path.IpfsPath(ch.After)
|
||||
res[i].After = path.FromCid(ch.After)
|
||||
}
|
||||
}
|
||||
return res, nil
|
||||
|
@ -3,50 +3,46 @@ package rpc
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/ipfs/boxo/coreiface/path"
|
||||
ipfspath "github.com/ipfs/boxo/path"
|
||||
"github.com/ipfs/boxo/path"
|
||||
cid "github.com/ipfs/go-cid"
|
||||
ipld "github.com/ipfs/go-ipld-format"
|
||||
)
|
||||
|
||||
func (api *HttpApi) ResolvePath(ctx context.Context, p path.Path) (path.Resolved, error) {
|
||||
func (api *HttpApi) ResolvePath(ctx context.Context, p path.Path) (path.ImmutablePath, []string, error) {
|
||||
var out struct {
|
||||
Cid cid.Cid
|
||||
RemPath string
|
||||
}
|
||||
|
||||
// TODO: this is hacky, fixing https://github.com/ipfs/go-ipfs/issues/5703 would help
|
||||
|
||||
var err error
|
||||
if p.Namespace() == "ipns" {
|
||||
if p.Namespace() == path.IPNSNamespace {
|
||||
if p, err = api.Name().Resolve(ctx, p.String()); err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if err := api.Request("dag/resolve", p.String()).Exec(ctx, &out); err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO:
|
||||
ipath, err := ipfspath.FromSegments("/"+p.Namespace()+"/", out.Cid.String(), out.RemPath)
|
||||
p, err = path.NewPathFromSegments(p.Namespace(), out.Cid.String(), out.RemPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
root, err := cid.Parse(ipfspath.Path(p.String()).Segments()[1])
|
||||
imPath, err := path.NewImmutablePath(p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return path.NewResolvedPath(ipath, out.Cid, root, out.RemPath), nil
|
||||
return imPath, path.StringToSegments(out.RemPath), nil
|
||||
}
|
||||
|
||||
func (api *HttpApi) ResolveNode(ctx context.Context, p path.Path) (ipld.Node, error) {
|
||||
rp, err := api.ResolvePath(ctx, p)
|
||||
rp, _, err := api.ResolvePath(ctx, p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return api.Dag().Get(ctx, rp.Cid())
|
||||
return api.Dag().Get(ctx, rp.RootCid())
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
|
||||
iface "github.com/ipfs/boxo/coreiface"
|
||||
caopts "github.com/ipfs/boxo/coreiface/options"
|
||||
"github.com/ipfs/boxo/coreiface/path"
|
||||
"github.com/ipfs/boxo/path"
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@ -24,7 +24,7 @@ type pinRefKeyList struct {
|
||||
}
|
||||
|
||||
type pin struct {
|
||||
path path.Resolved
|
||||
path path.ImmutablePath
|
||||
typ string
|
||||
err error
|
||||
}
|
||||
@ -33,7 +33,7 @@ func (p pin) Err() error {
|
||||
return p.err
|
||||
}
|
||||
|
||||
func (p pin) Path() path.Resolved {
|
||||
func (p pin) Path() path.ImmutablePath {
|
||||
return p.path
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ func (api *PinAPI) Ls(ctx context.Context, opts ...caopts.PinLsOption) (<-chan i
|
||||
}
|
||||
|
||||
select {
|
||||
case ch <- pin{typ: out.Type, path: path.IpldPath(c)}:
|
||||
case ch <- pin{typ: out.Type, path: path.FromCid(c)}:
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
@ -182,8 +182,8 @@ type badNode struct {
|
||||
cid cid.Cid
|
||||
}
|
||||
|
||||
func (n badNode) Path() path.Resolved {
|
||||
return path.IpldPath(n.cid)
|
||||
func (n badNode) Path() path.ImmutablePath {
|
||||
return path.FromCid(n.cid)
|
||||
}
|
||||
|
||||
func (n badNode) Err() error {
|
||||
|
@ -9,10 +9,10 @@ import (
|
||||
|
||||
iface "github.com/ipfs/boxo/coreiface"
|
||||
caopts "github.com/ipfs/boxo/coreiface/options"
|
||||
"github.com/ipfs/boxo/coreiface/path"
|
||||
"github.com/ipfs/boxo/files"
|
||||
unixfs "github.com/ipfs/boxo/ipld/unixfs"
|
||||
unixfs_pb "github.com/ipfs/boxo/ipld/unixfs/pb"
|
||||
"github.com/ipfs/boxo/path"
|
||||
"github.com/ipfs/go-cid"
|
||||
mh "github.com/multiformats/go-multihash"
|
||||
)
|
||||
@ -26,7 +26,7 @@ type addEvent struct {
|
||||
|
||||
type UnixfsAPI HttpApi
|
||||
|
||||
func (api *UnixfsAPI) Add(ctx context.Context, f files.Node, opts ...caopts.UnixfsAddOption) (path.Resolved, error) {
|
||||
func (api *UnixfsAPI) Add(ctx context.Context, f files.Node, opts ...caopts.UnixfsAddOption) (path.ImmutablePath, error) {
|
||||
options, _, err := caopts.UnixfsAddOptions(opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -105,7 +105,7 @@ loop:
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ifevt.Path = path.IpfsPath(c)
|
||||
ifevt.Path = path.FromCid(c)
|
||||
}
|
||||
|
||||
select {
|
||||
@ -121,7 +121,7 @@ loop:
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return path.IpfsPath(c), nil
|
||||
return path.FromCid(c), nil
|
||||
}
|
||||
|
||||
type lsLink struct {
|
||||
|
Reference in New Issue
Block a user