fix up core.Resolve a bit
Jeromy committed
Apr 22, 2015 at 23:20 UTC
c1560befcd509d5d96d5fa65902ed36cc5d9e2a3
2 files changed
+8
-6
core/commands/publish.go
+3
-5
@@ -8,7 +8,6 @@ import (
8
9
cmds "github.com/ipfs/go-ipfs/commands"
10
core "github.com/ipfs/go-ipfs/core"
11
- nsys "github.com/ipfs/go-ipfs/namesys"
11
crypto "github.com/ipfs/go-ipfs/p2p/crypto"
12
path "github.com/ipfs/go-ipfs/path"
13
u "github.com/ipfs/go-ipfs/util"
@@ -77,6 +76,7 @@ Publish an <ipfs-path> to another public key (not implemented):
76
// name = args[0]
77
pstr = args[1]
78
res.SetError(errors.New("keychains not yet implemented"), cmds.ErrNormal)
79
+ return
80
case 1:
81
// name = n.Identity.ID.String()
82
pstr = args[0]
@@ -108,14 +108,12 @@ Publish an <ipfs-path> to another public key (not implemented):
108
109
func publish(n *core.IpfsNode, k crypto.PrivKey, ref path.Path) (*IpnsEntry, error) {
110
// First, verify the path exists
111
- _, err := n.Resolver.ResolvePath(ref)
111
+ _, err := core.Resolve(n, ref)
112
if err != nil {
113
return nil, err
114
}
115
116
- pub := nsys.NewRoutingPublisher(n.Routing)
117
-
118
- err = pub.Publish(n.Context(), k, ref)
116
+ err = n.Namesys.Publish(n.Context(), k, ref)
117
if err != nil {
118
return nil, err
119
}
path/path.go
+5
-1
@@ -45,7 +45,11 @@ func (p Path) String() string {
45
}
46
47
func FromSegments(seg ...string) Path {
48
- return Path(strings.Join(seg, "/"))
48
+ var pref string
49
+ if seg[0] == "ipfs" || seg[0] == "ipns" {
50
+ pref = "/"
51
+ }
52
+ return Path(pref + strings.Join(seg, "/"))
53
}
54
55
func ParsePath(txt string) (Path, error) {