Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
2a41e76b
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2a41e76b
编写于
5月 21, 2017
作者:
L
Lewis Marshall
提交者:
Jeffrey Wilcke
5月 22, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
swarm/api: Fix adding paths which exist as manifests (#14482)
Signed-off-by:
N
Lewis Marshall
<
lewis@lmars.net
>
上级
4a2c17b1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
2 deletion
+35
-2
swarm/api/manifest.go
swarm/api/manifest.go
+2
-2
swarm/api/manifest_test.go
swarm/api/manifest_test.go
+33
-0
未找到文件。
swarm/api/manifest.go
浏览文件 @
2a41e76b
...
...
@@ -237,12 +237,12 @@ func (self *manifestTrie) addEntry(entry *manifestTrieEntry, quitC chan bool) {
}
b
:=
byte
(
entry
.
Path
[
0
])
if
(
self
.
entries
[
b
]
==
nil
)
||
(
self
.
entries
[
b
]
.
Path
==
entry
.
Path
)
{
oldentry
:=
self
.
entries
[
b
]
if
(
oldentry
==
nil
)
||
(
oldentry
.
Path
==
entry
.
Path
&&
oldentry
.
ContentType
!=
ManifestType
)
{
self
.
entries
[
b
]
=
entry
return
}
oldentry
:=
self
.
entries
[
b
]
cpl
:=
0
for
(
len
(
entry
.
Path
)
>
cpl
)
&&
(
len
(
oldentry
.
Path
)
>
cpl
)
&&
(
entry
.
Path
[
cpl
]
==
oldentry
.
Path
[
cpl
])
{
cpl
++
...
...
swarm/api/manifest_test.go
浏览文件 @
2a41e76b
...
...
@@ -18,6 +18,8 @@ package api
import
(
// "encoding/json"
"bytes"
"encoding/json"
"fmt"
"io"
"strings"
...
...
@@ -78,3 +80,34 @@ func TestGetEntry(t *testing.T) {
func
TestDeleteEntry
(
t
*
testing
.
T
)
{
}
// TestAddFileWithManifestPath tests that adding an entry at a path which
// already exists as a manifest just adds the entry to the manifest rather
// than replacing the manifest with the entry
func
TestAddFileWithManifestPath
(
t
*
testing
.
T
)
{
// create a manifest containing "ab" and "ac"
manifest
,
_
:=
json
.
Marshal
(
&
Manifest
{
Entries
:
[]
ManifestEntry
{
{
Path
:
"ab"
,
Hash
:
"ab"
},
{
Path
:
"ac"
,
Hash
:
"ac"
},
},
})
reader
:=
&
storage
.
LazyTestSectionReader
{
SectionReader
:
io
.
NewSectionReader
(
bytes
.
NewReader
(
manifest
),
0
,
int64
(
len
(
manifest
))),
}
trie
,
err
:=
readManifest
(
reader
,
nil
,
nil
,
nil
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
checkEntry
(
t
,
"ab"
,
"ab"
,
trie
)
checkEntry
(
t
,
"ac"
,
"ac"
,
trie
)
// now add path "a" and check we can still get "ab" and "ac"
entry
:=
&
manifestTrieEntry
{}
entry
.
Path
=
"a"
entry
.
Hash
=
"a"
trie
.
addEntry
(
entry
,
nil
)
checkEntry
(
t
,
"ab"
,
"ab"
,
trie
)
checkEntry
(
t
,
"ac"
,
"ac"
,
trie
)
checkEntry
(
t
,
"a"
,
"a"
,
trie
)
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录