Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-merkledag
Commits
68870d03
Commit
68870d03
authored
Nov 24, 2015
by
rht
Committed by
Jeromy
Jan 12, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
strings.Split -> path.SplitList
License: MIT Signed-off-by:
rht
<
rhtbot@gmail.com
>
parent
ef322f3c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
utils/utils.go
utils/utils.go
+5
-5
utils/utils_test.go
utils/utils_test.go
+3
-3
No files found.
utils/utils.go
View file @
68870d03
...
@@ -2,7 +2,6 @@ package dagutils
...
@@ -2,7 +2,6 @@ package dagutils
import
(
import
(
"errors"
"errors"
"strings"
ds
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
ds
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
syncds
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
syncds
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
...
@@ -12,6 +11,7 @@ import (
...
@@ -12,6 +11,7 @@ import (
bserv
"github.com/ipfs/go-ipfs/blockservice"
bserv
"github.com/ipfs/go-ipfs/blockservice"
offline
"github.com/ipfs/go-ipfs/exchange/offline"
offline
"github.com/ipfs/go-ipfs/exchange/offline"
dag
"github.com/ipfs/go-ipfs/merkledag"
dag
"github.com/ipfs/go-ipfs/merkledag"
path
"github.com/ipfs/go-ipfs/path"
)
)
type
Editor
struct
{
type
Editor
struct
{
...
@@ -76,8 +76,8 @@ func addLink(ctx context.Context, ds dag.DAGService, root *dag.Node, childname s
...
@@ -76,8 +76,8 @@ func addLink(ctx context.Context, ds dag.DAGService, root *dag.Node, childname s
return
root
,
nil
return
root
,
nil
}
}
func
(
e
*
Editor
)
InsertNodeAtPath
(
ctx
context
.
Context
,
p
a
th
string
,
toinsert
*
dag
.
Node
,
create
func
()
*
dag
.
Node
)
error
{
func
(
e
*
Editor
)
InsertNodeAtPath
(
ctx
context
.
Context
,
pth
string
,
toinsert
*
dag
.
Node
,
create
func
()
*
dag
.
Node
)
error
{
splpath
:=
strings
.
Split
(
p
a
th
,
"/"
)
splpath
:=
path
.
Split
List
(
pth
)
nd
,
err
:=
e
.
insertNodeAtPath
(
ctx
,
e
.
root
,
splpath
,
toinsert
,
create
)
nd
,
err
:=
e
.
insertNodeAtPath
(
ctx
,
e
.
root
,
splpath
,
toinsert
,
create
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -130,8 +130,8 @@ func (e *Editor) insertNodeAtPath(ctx context.Context, root *dag.Node, path []st
...
@@ -130,8 +130,8 @@ func (e *Editor) insertNodeAtPath(ctx context.Context, root *dag.Node, path []st
return
root
,
nil
return
root
,
nil
}
}
func
(
e
*
Editor
)
RmLink
(
ctx
context
.
Context
,
p
a
th
string
)
error
{
func
(
e
*
Editor
)
RmLink
(
ctx
context
.
Context
,
pth
string
)
error
{
splpath
:=
strings
.
Split
(
p
a
th
,
"/"
)
splpath
:=
path
.
Split
List
(
pth
)
nd
,
err
:=
e
.
rmLink
(
ctx
,
e
.
root
,
splpath
)
nd
,
err
:=
e
.
rmLink
(
ctx
,
e
.
root
,
splpath
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
utils/utils_test.go
View file @
68870d03
package
dagutils
package
dagutils
import
(
import
(
"strings"
"testing"
"testing"
key
"github.com/ipfs/go-ipfs/blocks/key"
key
"github.com/ipfs/go-ipfs/blocks/key"
dag
"github.com/ipfs/go-ipfs/merkledag"
dag
"github.com/ipfs/go-ipfs/merkledag"
mdtest
"github.com/ipfs/go-ipfs/merkledag/test"
mdtest
"github.com/ipfs/go-ipfs/merkledag/test"
path
"github.com/ipfs/go-ipfs/path"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
)
)
...
@@ -43,8 +43,8 @@ func TestAddLink(t *testing.T) {
...
@@ -43,8 +43,8 @@ func TestAddLink(t *testing.T) {
}
}
}
}
func
assertNodeAtPath
(
t
*
testing
.
T
,
ds
dag
.
DAGService
,
root
*
dag
.
Node
,
p
a
th
string
,
exp
key
.
Key
)
{
func
assertNodeAtPath
(
t
*
testing
.
T
,
ds
dag
.
DAGService
,
root
*
dag
.
Node
,
pth
string
,
exp
key
.
Key
)
{
parts
:=
strings
.
Split
(
p
a
th
,
"/"
)
parts
:=
path
.
Split
List
(
pth
)
cur
:=
root
cur
:=
root
for
_
,
e
:=
range
parts
{
for
_
,
e
:=
range
parts
{
nxt
,
err
:=
cur
.
GetLinkedNode
(
context
.
Background
(),
ds
,
e
)
nxt
,
err
:=
cur
.
GetLinkedNode
(
context
.
Background
(),
ds
,
e
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment