Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
ed2bb81b
提交
ed2bb81b
authored
6月 26, 2018
作者:
Kevin Atkinson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Code cleanups to make code climate happy.
License: MIT Signed-off-by:
Kevin Atkinson
<
k@kevina.org
>
上级
0e244442
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
12 行增加
和
11 行删除
+12
-11
root.go
core/commands/root.go
+1
-1
urlstore.go
core/commands/urlstore.go
+1
-1
fsrefstore.go
filestore/fsrefstore.go
+10
-9
没有找到文件。
core/commands/root.go
浏览文件 @
ed2bb81b
...
@@ -136,7 +136,7 @@ var rootSubcommands = map[string]*cmds.Command{
...
@@ -136,7 +136,7 @@ var rootSubcommands = map[string]*cmds.Command{
"tar"
:
lgc
.
NewCommand
(
TarCmd
),
"tar"
:
lgc
.
NewCommand
(
TarCmd
),
"file"
:
lgc
.
NewCommand
(
unixfs
.
UnixFSCmd
),
"file"
:
lgc
.
NewCommand
(
unixfs
.
UnixFSCmd
),
"update"
:
lgc
.
NewCommand
(
ExternalBinary
()),
"update"
:
lgc
.
NewCommand
(
ExternalBinary
()),
"urlstore"
:
lgc
.
NewCommand
(
U
rlStoreCmd
),
"urlstore"
:
lgc
.
NewCommand
(
u
rlStoreCmd
),
"version"
:
lgc
.
NewCommand
(
VersionCmd
),
"version"
:
lgc
.
NewCommand
(
VersionCmd
),
"shutdown"
:
lgc
.
NewCommand
(
daemonShutdownCmd
),
"shutdown"
:
lgc
.
NewCommand
(
daemonShutdownCmd
),
}
}
...
...
core/commands/urlstore.go
浏览文件 @
ed2bb81b
...
@@ -16,7 +16,7 @@ import (
...
@@ -16,7 +16,7 @@ import (
cmdkit
"gx/ipfs/QmdE4gMduCKCGAcczM2F5ioYDfdeKuPix138wrES1YSr7f/go-ipfs-cmdkit"
cmdkit
"gx/ipfs/QmdE4gMduCKCGAcczM2F5ioYDfdeKuPix138wrES1YSr7f/go-ipfs-cmdkit"
)
)
var
U
rlStoreCmd
=
&
cmds
.
Command
{
var
u
rlStoreCmd
=
&
cmds
.
Command
{
Subcommands
:
map
[
string
]
*
cmds
.
Command
{
Subcommands
:
map
[
string
]
*
cmds
.
Command
{
"add"
:
urlAdd
,
"add"
:
urlAdd
,
...
...
filestore/fsrefstore.go
浏览文件 @
ed2bb81b
...
@@ -123,11 +123,10 @@ func (f *FileManager) Get(c *cid.Cid) (blocks.Block, error) {
...
@@ -123,11 +123,10 @@ func (f *FileManager) Get(c *cid.Cid) (blocks.Block, error) {
}
}
func
(
f
*
FileManager
)
readDataObj
(
c
*
cid
.
Cid
,
d
*
pb
.
DataObj
)
([]
byte
,
error
)
{
func
(
f
*
FileManager
)
readDataObj
(
c
*
cid
.
Cid
,
d
*
pb
.
DataObj
)
([]
byte
,
error
)
{
if
!
IsURL
(
d
.
GetFilePath
())
{
if
IsURL
(
d
.
GetFilePath
())
{
return
f
.
readFileDataObj
(
c
,
d
)
}
else
{
return
f
.
readURLDataObj
(
c
,
d
)
return
f
.
readURLDataObj
(
c
,
d
)
}
}
return
f
.
readFileDataObj
(
c
,
d
)
}
}
func
(
f
*
FileManager
)
getDataObj
(
c
*
cid
.
Cid
)
(
*
pb
.
DataObj
,
error
)
{
func
(
f
*
FileManager
)
getDataObj
(
c
*
cid
.
Cid
)
(
*
pb
.
DataObj
,
error
)
{
...
@@ -266,7 +265,12 @@ func (f *FileManager) Put(b *posinfo.FilestoreNode) error {
...
@@ -266,7 +265,12 @@ func (f *FileManager) Put(b *posinfo.FilestoreNode) error {
func
(
f
*
FileManager
)
putTo
(
b
*
posinfo
.
FilestoreNode
,
to
putter
)
error
{
func
(
f
*
FileManager
)
putTo
(
b
*
posinfo
.
FilestoreNode
,
to
putter
)
error
{
var
dobj
pb
.
DataObj
var
dobj
pb
.
DataObj
if
!
IsURL
(
b
.
PosInfo
.
FullPath
)
{
if
IsURL
(
b
.
PosInfo
.
FullPath
)
{
if
!
f
.
AllowUrls
{
return
fmt
.
Errorf
(
"urlstore not enabled"
)
}
dobj
.
FilePath
=
proto
.
String
(
b
.
PosInfo
.
FullPath
)
}
else
{
if
!
f
.
AllowFiles
{
if
!
f
.
AllowFiles
{
return
fmt
.
Errorf
(
"filestore not enabled"
)
return
fmt
.
Errorf
(
"filestore not enabled"
)
}
}
...
@@ -280,11 +284,6 @@ func (f *FileManager) putTo(b *posinfo.FilestoreNode, to putter) error {
...
@@ -280,11 +284,6 @@ func (f *FileManager) putTo(b *posinfo.FilestoreNode, to putter) error {
}
}
dobj
.
FilePath
=
proto
.
String
(
filepath
.
ToSlash
(
p
))
dobj
.
FilePath
=
proto
.
String
(
filepath
.
ToSlash
(
p
))
}
else
{
if
!
f
.
AllowUrls
{
return
fmt
.
Errorf
(
"urlstore not enabled"
)
}
dobj
.
FilePath
=
proto
.
String
(
b
.
PosInfo
.
FullPath
)
}
}
dobj
.
Offset
=
proto
.
Uint64
(
b
.
PosInfo
.
Offset
)
dobj
.
Offset
=
proto
.
Uint64
(
b
.
PosInfo
.
Offset
)
dobj
.
Size_
=
proto
.
Uint64
(
uint64
(
len
(
b
.
RawData
())))
dobj
.
Size_
=
proto
.
Uint64
(
uint64
(
len
(
b
.
RawData
())))
...
@@ -314,6 +313,8 @@ func (f *FileManager) PutMany(bs []*posinfo.FilestoreNode) error {
...
@@ -314,6 +313,8 @@ func (f *FileManager) PutMany(bs []*posinfo.FilestoreNode) error {
return
batch
.
Commit
()
return
batch
.
Commit
()
}
}
// IsURL returns true if the string represents a valid URL that the
// urlstore can handle.
func
IsURL
(
str
string
)
bool
{
func
IsURL
(
str
string
)
bool
{
return
(
len
(
str
)
>
7
&&
str
[
0
]
==
'h'
&&
str
[
1
]
==
't'
&&
str
[
2
]
==
't'
&&
str
[
3
]
==
'p'
)
&&
return
(
len
(
str
)
>
7
&&
str
[
0
]
==
'h'
&&
str
[
1
]
==
't'
&&
str
[
2
]
==
't'
&&
str
[
3
]
==
'p'
)
&&
((
len
(
str
)
>
8
&&
str
[
4
]
==
's'
&&
str
[
5
]
==
':'
&&
str
[
6
]
==
'/'
&&
str
[
7
]
==
'/'
)
||
((
len
(
str
)
>
8
&&
str
[
4
]
==
's'
&&
str
[
5
]
==
':'
&&
str
[
6
]
==
'/'
&&
str
[
7
]
==
'/'
)
||
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论