Skip to content

Commit

Permalink
Merge pull request #1275 from ipfs/fix/resolution
Browse files Browse the repository at this point in the history
fix offline full path resolution bug
  • Loading branch information
whyrusleeping committed May 21, 2015
2 parents 5853eac + 60ac591 commit 8b94abd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/pathresolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ var ErrNoNamesys = errors.New(
// entries and returning the final merkledage node. Effectively
// enables /ipns/, /dns/, etc. in commands.
func Resolve(ctx context.Context, n *IpfsNode, p path.Path) (*merkledag.Node, error) {
if strings.HasPrefix(p.String(), "/") {
// namespaced path (/ipfs/..., /ipns/..., etc.)
if strings.HasPrefix(p.String(), "/ipns/") {
// resolve ipns paths

// TODO(cryptix): we sould be able to query the local cache for the path
if n.Namesys == nil {
return nil, ErrNoNamesys
Expand Down
34 changes: 34 additions & 0 deletions test/sharness/t0041-add-cat-offline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh
#
# Copyright (c) 2014 Jeromy Johnson
# MIT Licensed; see the LICENSE file in this repository.
#

test_description="Test add and cat commands"

. lib/test-lib.sh

test_init_ipfs

test_expect_success "ipfs add file succeeds" '
echo "some content" > afile &&
HASH=$(ipfs add -q afile)
'

test_expect_success "ipfs cat file suceeds" '
ipfs cat $HASH > out_1
'

test_expect_success "output looks good" '
test_cmp afile out_1
'

test_expect_success "ipfs cat /ipfs/file succeeds" '
ipfs cat /ipfs/$HASH > out_2
'

test_expect_success "output looks good" '
test_cmp afile out_2
'

test_done

0 comments on commit 8b94abd

Please sign in to comment.