mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-25 15:08:45 +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
|
||||
}
|
||||
|
||||
if !node.OnlineMode() {
|
||||
if err := node.SetupOfflineRouting(); err != nil {
|
||||
res.SetError(err, cmds.ErrNormal)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
readers, length, err := cat(req.Context(), node, req.Arguments())
|
||||
if err != nil {
|
||||
res.SetError(err, cmds.ErrNormal)
|
||||
|
@ -8,8 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func Cat(ctx context.Context, n *core.IpfsNode, pstr string) (*uio.DagReader, error) {
|
||||
p := path.FromString(pstr)
|
||||
dagNode, err := n.Resolver.ResolvePath(ctx, p)
|
||||
dagNode, err := core.Resolve(ctx, n, path.Path(pstr))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -54,6 +54,12 @@ test_expect_success "resolve output looks good" '
|
||||
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
|
||||
|
||||
test_expect_failure "'ipfs name publish <local-id> <hash>' succeeds" '
|
||||
|
Reference in New Issue
Block a user