Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
caa7ac0e
提交
caa7ac0e
authored
1月 06, 2015
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #495 from jbenet/sharness-add-recursive
sharness test: ipfs add -r
上级
e1cde6bc
3b65f1a5
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
44 行增加
和
0 行删除
+44
-0
add.go
core/commands/add.go
+16
-0
coding.go
merkledag/coding.go
+5
-0
merkledag.go
merkledag/merkledag.go
+6
-0
t0040-add-and-cat.sh
test/t0040-add-and-cat.sh
+17
-0
没有找到文件。
core/commands/add.go
浏览文件 @
caa7ac0e
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"fmt"
"fmt"
"io"
"io"
"path"
"path"
"sort"
cmds
"github.com/jbenet/go-ipfs/commands"
cmds
"github.com/jbenet/go-ipfs/commands"
core
"github.com/jbenet/go-ipfs/core"
core
"github.com/jbenet/go-ipfs/core"
...
@@ -82,6 +83,8 @@ remains to be implemented.
...
@@ -82,6 +83,8 @@ remains to be implemented.
return
nil
,
u
.
ErrCast
()
return
nil
,
u
.
ErrCast
()
}
}
sort
.
Stable
(
val
)
var
buf
bytes
.
Buffer
var
buf
bytes
.
Buffer
for
i
,
obj
:=
range
val
.
Objects
{
for
i
,
obj
:=
range
val
.
Objects
{
if
val
.
Quiet
{
if
val
.
Quiet
{
...
@@ -197,3 +200,16 @@ func addDagnode(output *AddOutput, name string, dn *dag.Node) error {
...
@@ -197,3 +200,16 @@ func addDagnode(output *AddOutput, name string, dn *dag.Node) error {
output
.
Names
=
append
(
output
.
Names
,
name
)
output
.
Names
=
append
(
output
.
Names
,
name
)
return
nil
return
nil
}
}
// Sort interface implementation to sort add output by name
func
(
a
AddOutput
)
Len
()
int
{
return
len
(
a
.
Names
)
}
func
(
a
AddOutput
)
Swap
(
i
,
j
int
)
{
a
.
Names
[
i
],
a
.
Names
[
j
]
=
a
.
Names
[
j
],
a
.
Names
[
i
]
a
.
Objects
[
i
],
a
.
Objects
[
j
]
=
a
.
Objects
[
j
],
a
.
Objects
[
i
]
}
func
(
a
AddOutput
)
Less
(
i
,
j
int
)
bool
{
return
a
.
Names
[
i
]
<
a
.
Names
[
j
]
}
merkledag/coding.go
浏览文件 @
caa7ac0e
...
@@ -2,6 +2,7 @@ package merkledag
...
@@ -2,6 +2,7 @@ package merkledag
import
(
import
(
"fmt"
"fmt"
"sort"
mh
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
mh
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
...
@@ -30,6 +31,7 @@ func (n *Node) Unmarshal(encoded []byte) error {
...
@@ -30,6 +31,7 @@ func (n *Node) Unmarshal(encoded []byte) error {
}
}
n
.
Links
[
i
]
.
Hash
=
h
n
.
Links
[
i
]
.
Hash
=
h
}
}
sort
.
Stable
(
LinkSlice
(
n
.
Links
))
// keep links sorted
n
.
Data
=
pbn
.
GetData
()
n
.
Data
=
pbn
.
GetData
()
return
nil
return
nil
...
@@ -59,6 +61,8 @@ func (n *Node) Marshal() ([]byte, error) {
...
@@ -59,6 +61,8 @@ func (n *Node) Marshal() ([]byte, error) {
func
(
n
*
Node
)
getPBNode
()
*
pb
.
PBNode
{
func
(
n
*
Node
)
getPBNode
()
*
pb
.
PBNode
{
pbn
:=
&
pb
.
PBNode
{}
pbn
:=
&
pb
.
PBNode
{}
pbn
.
Links
=
make
([]
*
pb
.
PBLink
,
len
(
n
.
Links
))
pbn
.
Links
=
make
([]
*
pb
.
PBLink
,
len
(
n
.
Links
))
sort
.
Stable
(
LinkSlice
(
n
.
Links
))
// keep links sorted
for
i
,
l
:=
range
n
.
Links
{
for
i
,
l
:=
range
n
.
Links
{
pbn
.
Links
[
i
]
=
&
pb
.
PBLink
{}
pbn
.
Links
[
i
]
=
&
pb
.
PBLink
{}
pbn
.
Links
[
i
]
.
Name
=
&
l
.
Name
pbn
.
Links
[
i
]
.
Name
=
&
l
.
Name
...
@@ -73,6 +77,7 @@ func (n *Node) getPBNode() *pb.PBNode {
...
@@ -73,6 +77,7 @@ func (n *Node) getPBNode() *pb.PBNode {
// Encoded returns the encoded raw data version of a Node instance.
// Encoded returns the encoded raw data version of a Node instance.
// It may use a cached encoded version, unless the force flag is given.
// It may use a cached encoded version, unless the force flag is given.
func
(
n
*
Node
)
Encoded
(
force
bool
)
([]
byte
,
error
)
{
func
(
n
*
Node
)
Encoded
(
force
bool
)
([]
byte
,
error
)
{
sort
.
Stable
(
LinkSlice
(
n
.
Links
))
// keep links sorted
if
n
.
encoded
==
nil
||
force
{
if
n
.
encoded
==
nil
||
force
{
var
err
error
var
err
error
n
.
encoded
,
err
=
n
.
Marshal
()
n
.
encoded
,
err
=
n
.
Marshal
()
...
...
merkledag/merkledag.go
浏览文件 @
caa7ac0e
...
@@ -66,6 +66,12 @@ type Link struct {
...
@@ -66,6 +66,12 @@ type Link struct {
Node
*
Node
Node
*
Node
}
}
type
LinkSlice
[]
*
Link
func
(
ls
LinkSlice
)
Len
()
int
{
return
len
(
ls
)
}
func
(
ls
LinkSlice
)
Swap
(
a
,
b
int
)
{
ls
[
a
],
ls
[
b
]
=
ls
[
b
],
ls
[
a
]
}
func
(
ls
LinkSlice
)
Less
(
a
,
b
int
)
bool
{
return
ls
[
a
]
.
Name
<
ls
[
b
]
.
Name
}
// MakeLink creates a link to the given node
// MakeLink creates a link to the given node
func
MakeLink
(
n
*
Node
)
(
*
Link
,
error
)
{
func
MakeLink
(
n
*
Node
)
(
*
Link
,
error
)
{
s
,
err
:=
n
.
Size
()
s
,
err
:=
n
.
Size
()
...
...
test/t0040-add-and-cat.sh
浏览文件 @
caa7ac0e
...
@@ -67,6 +67,23 @@ test_expect_success "'ipfs add -q' output looks good" '
...
@@ -67,6 +67,23 @@ test_expect_success "'ipfs add -q' output looks good" '
test_cmp expected actual
test_cmp expected actual
'
'
test_expect_success
"'ipfs add -r' succeeds"
'
mkdir mountdir/planets &&
echo "Hello Mars!" >mountdir/planets/mars.txt &&
echo "Hello Venus!" >mountdir/planets/venus.txt &&
ipfs add -r mountdir/planets >actual
'
test_expect_success
"'ipfs add -r' output looks good"
'
PLANETS="QmWSgS32xQEcXMeqd3YPJLrNBLSdsfYCep2U7CFkyrjXwY" &&
MARS="QmPrrHqJzto9m7SyiRzarwkqPcCSsKR2EB1AyqJfe8L8tN" &&
VENUS="QmU5kp3BH3B8tnWUU2Pikdb2maksBNkb92FHRr56hyghh4" &&
echo "added $PLANETS mountdir/planets" >expected &&
echo "added $MARS mountdir/planets/mars.txt" >>expected &&
echo "added $VENUS mountdir/planets/venus.txt" >>expected &&
test_cmp expected actual
'
test_expect_success
"go-random is installed"
'
test_expect_success
"go-random is installed"
'
type random
type random
'
'
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论