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-dms3
Commits
9ddfafb4
Commit
9ddfafb4
authored
10 years ago
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
address concerns about user interface with new Path type
parent
1c891dbd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
12 deletions
+27
-12
core/coreunix/add.go
core/coreunix/add.go
+9
-5
core/coreunix/cat.go
core/coreunix/cat.go
+2
-1
path/path.go
path/path.go
+12
-0
test/integration/addcat_test.go
test/integration/addcat_test.go
+2
-3
test/integration/three_legged_cat_test.go
test/integration/three_legged_cat_test.go
+2
-3
No files found.
core/coreunix/add.go
View file @
9ddfafb4
...
...
@@ -4,7 +4,7 @@ import (
"errors"
"io"
"os"
"path"
gopath
"path"
"github.com/jbenet/go-ipfs/commands/files"
core
"github.com/jbenet/go-ipfs/core"
...
...
@@ -14,14 +14,13 @@ import (
"github.com/jbenet/go-ipfs/pin"
"github.com/jbenet/go-ipfs/thirdparty/eventlog"
unixfs
"github.com/jbenet/go-ipfs/unixfs"
u
"github.com/jbenet/go-ipfs/util"
)
var
log
=
eventlog
.
Logger
(
"coreunix"
)
// Add builds a merkledag from the a reader, pinning all objects to the local
// datastore. Returns a key representing the root node.
func
Add
(
n
*
core
.
IpfsNode
,
r
io
.
Reader
)
(
u
.
Key
,
error
)
{
func
Add
(
n
*
core
.
IpfsNode
,
r
io
.
Reader
)
(
string
,
error
)
{
// TODO more attractive function signature importer.BuildDagFromReader
dagNode
,
err
:=
importer
.
BuildDagFromReader
(
r
,
...
...
@@ -35,7 +34,12 @@ func Add(n *core.IpfsNode, r io.Reader) (u.Key, error) {
if
err
:=
n
.
Pinning
.
Flush
();
err
!=
nil
{
return
""
,
err
}
return
dagNode
.
Key
()
k
,
err
:=
dagNode
.
Key
()
if
err
!=
nil
{
return
""
,
err
}
return
k
.
String
(),
nil
}
// AddR recursively adds files in |path|.
...
...
@@ -124,7 +128,7 @@ Loop:
return
nil
,
err
}
_
,
name
:=
path
.
Split
(
file
.
FileName
())
_
,
name
:=
go
path
.
Split
(
file
.
FileName
())
err
=
tree
.
AddNodeLink
(
name
,
node
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
core/coreunix/cat.go
View file @
9ddfafb4
...
...
@@ -8,7 +8,8 @@ import (
uio
"github.com/jbenet/go-ipfs/unixfs/io"
)
func
Cat
(
n
*
core
.
IpfsNode
,
p
path
.
Path
)
(
io
.
Reader
,
error
)
{
func
Cat
(
n
*
core
.
IpfsNode
,
pstr
string
)
(
io
.
Reader
,
error
)
{
p
:=
path
.
FromString
(
pstr
)
dagNode
,
err
:=
n
.
Resolver
.
ResolvePath
(
p
)
if
err
!=
nil
{
return
nil
,
err
...
...
This diff is collapsed.
Click to expand it.
path/path.go
View file @
9ddfafb4
...
...
@@ -3,12 +3,24 @@ package path
import
(
"path"
"strings"
u
"github.com/jbenet/go-ipfs/util"
)
// TODO: debate making this a private struct wrapped in a public interface
// would allow us to control creation, and cache segments.
type
Path
string
// FromString safely converts a string type to a Path type
func
FromString
(
s
string
)
Path
{
return
Path
(
s
)
}
// FromKey safely converts a Key type to a Path type
func
FromKey
(
k
u
.
Key
)
Path
{
return
Path
(
k
.
String
())
}
func
(
p
Path
)
Segments
()
[]
string
{
cleaned
:=
path
.
Clean
(
string
(
p
))
segments
:=
strings
.
Split
(
cleaned
,
"/"
)
...
...
This diff is collapsed.
Click to expand it.
test/integration/addcat_test.go
View file @
9ddfafb4
...
...
@@ -15,7 +15,6 @@ import (
coreunix
"github.com/jbenet/go-ipfs/core/coreunix"
mocknet
"github.com/jbenet/go-ipfs/p2p/net/mock"
"github.com/jbenet/go-ipfs/p2p/peer"
path
"github.com/jbenet/go-ipfs/path"
"github.com/jbenet/go-ipfs/thirdparty/unit"
errors
"github.com/jbenet/go-ipfs/util/debugerror"
testutil
"github.com/jbenet/go-ipfs/util/testutil"
...
...
@@ -126,12 +125,12 @@ func DirectAddCat(data []byte, conf testutil.LatencyConfig) error {
return
err
}
keyA
dded
,
err
:=
coreunix
.
Add
(
adder
,
bytes
.
NewReader
(
data
))
a
dded
,
err
:=
coreunix
.
Add
(
adder
,
bytes
.
NewReader
(
data
))
if
err
!=
nil
{
return
err
}
readerCatted
,
err
:=
coreunix
.
Cat
(
catter
,
path
.
Path
(
keyAdded
.
String
())
)
readerCatted
,
err
:=
coreunix
.
Cat
(
catter
,
added
)
if
err
!=
nil
{
return
err
}
...
...
This diff is collapsed.
Click to expand it.
test/integration/three_legged_cat_test.go
View file @
9ddfafb4
...
...
@@ -12,7 +12,6 @@ import (
coreunix
"github.com/jbenet/go-ipfs/core/coreunix"
mocknet
"github.com/jbenet/go-ipfs/p2p/net/mock"
"github.com/jbenet/go-ipfs/p2p/peer"
path
"github.com/jbenet/go-ipfs/path"
"github.com/jbenet/go-ipfs/thirdparty/unit"
errors
"github.com/jbenet/go-ipfs/util/debugerror"
testutil
"github.com/jbenet/go-ipfs/util/testutil"
...
...
@@ -106,12 +105,12 @@ func RunThreeLeggedCat(data []byte, conf testutil.LatencyConfig) error {
return
err
}
keyA
dded
,
err
:=
coreunix
.
Add
(
adder
,
bytes
.
NewReader
(
data
))
a
dded
,
err
:=
coreunix
.
Add
(
adder
,
bytes
.
NewReader
(
data
))
if
err
!=
nil
{
return
err
}
readerCatted
,
err
:=
coreunix
.
Cat
(
catter
,
path
.
Path
(
keyAdded
.
String
())
)
readerCatted
,
err
:=
coreunix
.
Cat
(
catter
,
added
)
if
err
!=
nil
{
return
err
}
...
...
This diff is collapsed.
Click to expand it.
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