Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
8fce0c41
提交
8fce0c41
authored
1月 30, 2017
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
validate data read from fsrefstore
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
上级
c18ec982
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
16 行增加
和
16 行删除
+16
-16
fsrefstore.go
filestore/fsrefstore.go
+12
-2
dataobj.pb.go
filestore/pb/dataobj.pb.go
+4
-12
dataobj.proto
filestore/pb/dataobj.proto
+0
-2
没有找到文件。
filestore/fsrefstore.go
浏览文件 @
8fce0c41
...
...
@@ -109,11 +109,21 @@ func (f *FileManager) Get(c *cid.Cid) (blocks.Block, error) {
return
nil
,
err
}
outcid
,
err
:=
c
.
Prefix
()
.
Sum
(
out
)
if
err
!=
nil
{
return
nil
,
err
}
if
!
c
.
Equals
(
outcid
)
{
return
nil
,
&
CorruptReferenceError
{
fmt
.
Errorf
(
"data in file did not match. %s offset %d"
,
dobj
.
GetFilePath
(),
dobj
.
GetOffset
())}
}
return
blocks
.
NewBlockWithCid
(
out
,
c
)
}
func
(
f
*
FileManager
)
readDataObj
(
d
*
pb
.
DataObj
)
([]
byte
,
error
)
{
abspath
:=
filepath
.
Join
(
f
.
root
,
d
.
GetFilePath
())
p
:=
filepath
.
FromSlash
(
d
.
GetFilePath
())
abspath
:=
filepath
.
Join
(
f
.
root
,
p
)
fi
,
err
:=
os
.
Open
(
abspath
)
if
err
!=
nil
{
...
...
@@ -162,7 +172,7 @@ func (f *FileManager) putTo(b *posinfo.FilestoreNode, to putter) error {
return
err
}
dobj
.
FilePath
=
proto
.
String
(
p
)
dobj
.
FilePath
=
proto
.
String
(
filepath
.
ToSlash
(
p
)
)
dobj
.
Offset
=
proto
.
Uint64
(
b
.
PosInfo
.
Offset
)
dobj
.
Size_
=
proto
.
Uint64
(
uint64
(
len
(
b
.
RawData
())))
...
...
filestore/pb/dataobj.pb.go
浏览文件 @
8fce0c41
...
...
@@ -23,11 +23,10 @@ var _ = fmt.Errorf
var
_
=
math
.
Inf
type
DataObj
struct
{
FilePath
*
string
`protobuf:"bytes,1,opt,name=FilePath" json:"FilePath,omitempty"`
Offset
*
uint64
`protobuf:"varint,2,opt,name=Offset" json:"Offset,omitempty"`
Size_
*
uint64
`protobuf:"varint,3,opt,name=Size" json:"Size,omitempty"`
Modtime
*
float64
`protobuf:"fixed64,4,opt,name=Modtime" json:"Modtime,omitempty"`
XXX_unrecognized
[]
byte
`json:"-"`
FilePath
*
string
`protobuf:"bytes,1,opt,name=FilePath" json:"FilePath,omitempty"`
Offset
*
uint64
`protobuf:"varint,2,opt,name=Offset" json:"Offset,omitempty"`
Size_
*
uint64
`protobuf:"varint,3,opt,name=Size" json:"Size,omitempty"`
XXX_unrecognized
[]
byte
`json:"-"`
}
func
(
m
*
DataObj
)
Reset
()
{
*
m
=
DataObj
{}
}
...
...
@@ -55,13 +54,6 @@ func (m *DataObj) GetSize_() uint64 {
return
0
}
func
(
m
*
DataObj
)
GetModtime
()
float64
{
if
m
!=
nil
&&
m
.
Modtime
!=
nil
{
return
*
m
.
Modtime
}
return
0
}
func
init
()
{
proto
.
RegisterType
((
*
DataObj
)(
nil
),
"datastore.pb.DataObj"
)
}
filestore/pb/dataobj.proto
浏览文件 @
8fce0c41
...
...
@@ -4,6 +4,4 @@ message DataObj {
optional
string
FilePath
=
1
;
optional
uint64
Offset
=
2
;
optional
uint64
Size
=
3
;
optional
double
Modtime
=
4
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论