mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-26 07:28:20 +08:00
Merge pull request #1919 from rht/cat-ipns
Allow `ipfs cat` on ipns path
This commit is contained in:
@ -31,6 +31,13 @@ it contains.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !node.OnlineMode() {
|
||||||
|
if err := node.SetupOfflineRouting(); err != nil {
|
||||||
|
res.SetError(err, cmds.ErrNormal)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
readers, length, err := cat(req.Context(), node, req.Arguments())
|
readers, length, err := cat(req.Context(), node, req.Arguments())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.SetError(err, cmds.ErrNormal)
|
res.SetError(err, cmds.ErrNormal)
|
||||||
|
@ -8,8 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Cat(ctx context.Context, n *core.IpfsNode, pstr string) (*uio.DagReader, error) {
|
func Cat(ctx context.Context, n *core.IpfsNode, pstr string) (*uio.DagReader, error) {
|
||||||
p := path.FromString(pstr)
|
dagNode, err := core.Resolve(ctx, n, path.Path(pstr))
|
||||||
dagNode, err := n.Resolver.ResolvePath(ctx, p)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,12 @@ test_expect_success "resolve output looks good" '
|
|||||||
test_cmp expected4 output
|
test_cmp expected4 output
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success "ipfs cat on published content succeeds" '
|
||||||
|
ipfs cat "/ipfs/$HASH_WELCOME_DOCS/help" >expected &&
|
||||||
|
ipfs cat "/ipns/$PEERID" >actual &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
# publish with an explicit node ID
|
# publish with an explicit node ID
|
||||||
|
|
||||||
test_expect_failure "'ipfs name publish <local-id> <hash>' succeeds" '
|
test_expect_failure "'ipfs name publish <local-id> <hash>' succeeds" '
|
||||||
|
Reference in New Issue
Block a user