Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
7a4491ad
提交
7a4491ad
authored
11月 18, 2014
作者:
Matt Bell
提交者:
Juan Batiz-Benet
11月 18, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added --mount flag to mount when running 'ipfs daemon'
上级
105f2321
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
69 行增加
和
25 行删除
+69
-25
daemon.go
cmd/ipfs2/daemon.go
+43
-9
mount_unix.go
core/commands2/mount_unix.go
+26
-16
没有找到文件。
cmd/ipfs2/daemon.go
浏览文件 @
7a4491ad
...
...
@@ -18,6 +18,9 @@ import (
const
(
initOptionKwd
=
"init"
mountKwd
=
"mount"
ipfsMountKwd
=
"mount-ipfs"
ipnsMountKwd
=
"mount-ipns"
)
var
daemonCmd
=
&
cmds
.
Command
{
...
...
@@ -34,12 +37,24 @@ the daemon.
Options
:
[]
cmds
.
Option
{
cmds
.
BoolOption
(
initOptionKwd
,
"Initialize IPFS with default settings if not already initialized"
),
cmds
.
BoolOption
(
mountKwd
,
"Mounts IPFS to the filesystem"
),
cmds
.
StringOption
(
ipfsMountKwd
,
"Path to the mountpoint for IPFS (if using --mount)"
),
cmds
.
StringOption
(
ipnsMountKwd
,
"Path to the mountpoint for IPNS (if using --mount)"
),
},
Subcommands
:
map
[
string
]
*
cmds
.
Command
{},
Run
:
daemonFunc
,
}
func
daemonFunc
(
req
cmds
.
Request
)
(
interface
{},
error
)
{
cfg
,
err
:=
req
.
Context
()
.
GetConfig
()
if
err
!=
nil
{
return
nil
,
err
}
node
,
err
:=
core
.
NewIpfsNode
(
cfg
,
true
)
if
err
!=
nil
{
return
nil
,
err
}
initialize
,
_
,
err
:=
req
.
Option
(
initOptionKwd
)
.
Bool
()
if
err
!=
nil
{
...
...
@@ -65,30 +80,49 @@ func daemonFunc(req cmds.Request) (interface{}, error) {
}
defer
lock
.
Close
()
cfg
,
err
:=
req
.
Context
()
.
GetConfig
()
if
err
!=
nil
{
return
nil
,
err
}
// setup function that constructs the context. we have to do it this way
// to play along with how the Context works and thus not expose its internals
req
.
Context
()
.
ConstructNode
=
func
()
(
*
core
.
IpfsNode
,
error
)
{
return
core
.
NewIpfsNode
(
cfg
,
true
)
return
node
,
nil
}
node
,
err
:=
req
.
Context
()
.
GetNode
()
addr
,
err
:=
ma
.
NewMultiaddr
(
cfg
.
Addresses
.
API
)
if
err
!=
nil
{
return
nil
,
err
}
addr
,
err
:=
ma
.
NewMultiaddr
(
cfg
.
Addresses
.
API
)
_
,
host
,
err
:=
manet
.
DialArgs
(
addr
)
if
err
!=
nil
{
return
nil
,
err
}
_
,
host
,
err
:=
manet
.
DialArgs
(
addr
)
// mount if the user provided the --mount flag
mount
,
_
,
err
:=
req
.
Option
(
mountKwd
)
.
Bool
()
if
err
!=
nil
{
return
nil
,
err
}
if
mount
{
fsdir
,
found
,
err
:=
req
.
Option
(
ipfsMountKwd
)
.
String
()
if
err
!=
nil
{
return
nil
,
err
}
if
!
found
{
fsdir
=
cfg
.
Mounts
.
IPFS
}
nsdir
,
found
,
err
:=
req
.
Option
(
ipnsMountKwd
)
.
String
()
if
err
!=
nil
{
return
nil
,
err
}
if
!
found
{
nsdir
=
cfg
.
Mounts
.
IPNS
}
err
=
commands
.
Mount
(
node
,
fsdir
,
nsdir
)
if
err
!=
nil
{
return
nil
,
err
}
}
mux
:=
http
.
NewServeMux
()
cmdHandler
:=
cmdsHttp
.
NewHandler
(
*
req
.
Context
(),
commands
.
Root
)
...
...
core/commands2/mount_unix.go
浏览文件 @
7a4491ad
...
...
@@ -100,25 +100,11 @@ baz
return
nil
,
err
}
// check if we already have live mounts.
// if the user said "Mount", then there must be something wrong.
// so, close them and try again.
if
node
.
Mounts
.
Ipfs
!=
nil
{
node
.
Mounts
.
Ipfs
.
Unmount
()
}
if
node
.
Mounts
.
Ipns
!=
nil
{
node
.
Mounts
.
Ipns
.
Unmount
()
}
// error if we aren't running node in online mode
if
node
.
Network
==
nil
{
if
!
node
.
OnlineMode
()
{
return
nil
,
errNotOnline
}
if
err
:=
platformFuseChecks
();
err
!=
nil
{
return
nil
,
err
}
fsdir
,
found
,
err
:=
req
.
Option
(
"f"
)
.
String
()
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -136,7 +122,8 @@ baz
nsdir
=
cfg
.
Mounts
.
IPNS
// NB: be sure to not redeclare!
}
if
err
:=
doMount
(
node
,
fsdir
,
nsdir
);
err
!=
nil
{
err
=
Mount
(
node
,
fsdir
,
nsdir
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -207,3 +194,26 @@ func doMount(node *core.IpfsNode, fsdir, nsdir string) error {
var
platformFuseChecks
=
func
()
error
{
return
nil
}
func
Mount
(
node
*
core
.
IpfsNode
,
fsdir
,
nsdir
string
)
error
{
// check if we already have live mounts.
// if the user said "Mount", then there must be something wrong.
// so, close them and try again.
if
node
.
Mounts
.
Ipfs
!=
nil
{
node
.
Mounts
.
Ipfs
.
Unmount
()
}
if
node
.
Mounts
.
Ipns
!=
nil
{
node
.
Mounts
.
Ipns
.
Unmount
()
}
if
err
:=
platformFuseChecks
();
err
!=
nil
{
return
err
}
var
err
error
if
err
=
doMount
(
node
,
fsdir
,
nsdir
);
err
!=
nil
{
return
err
}
return
nil
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论