From 1babd9d97ef2cfc2d18afdc59b86338d0cc3545a Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 21 May 2015 14:26:39 -0700 Subject: [PATCH] fix offline full path resolution bug --- core/pathresolver.go | 2 +- test/sharness/t0041-add-cat-offline.sh | 34 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100755 test/sharness/t0041-add-cat-offline.sh diff --git a/core/pathresolver.go b/core/pathresolver.go index f73a83fd364..c24d308859b 100644 --- a/core/pathresolver.go +++ b/core/pathresolver.go @@ -20,7 +20,7 @@ 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(), "/") { + if strings.HasPrefix(p.String(), "/ipns") { // namespaced path (/ipfs/..., /ipns/..., etc.) // TODO(cryptix): we sould be able to query the local cache for the path if n.Namesys == nil { diff --git a/test/sharness/t0041-add-cat-offline.sh b/test/sharness/t0041-add-cat-offline.sh new file mode 100755 index 00000000000..cb370eec009 --- /dev/null +++ b/test/sharness/t0041-add-cat-offline.sh @@ -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