Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
8f24d8e2
提交
8f24d8e2
authored
12月 20, 2017
作者:
keks
提交者:
Jeromy
1月 21, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cleanup
License: MIT Signed-off-by:
keks
<
keks@cryptoscope.co
>
上级
7b196390
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
22 行增加
和
79 行删除
+22
-79
daemon.go
cmd/ipfs/daemon.go
+9
-11
main.go
cmd/ipfs/main.go
+0
-3
legacy.go
commands/legacy/legacy.go
+0
-26
legacy_test.go
commands/legacy/legacy_test.go
+0
-29
request.go
commands/request.go
+4
-0
add.go
core/commands/add.go
+3
-1
cat.go
core/commands/cat.go
+1
-1
commands.go
core/commands/commands.go
+0
-1
get_test.go
core/commands/get_test.go
+4
-6
t0110-gateway.sh
test/sharness/t0110-gateway.sh
+1
-1
没有找到文件。
cmd/ipfs/daemon.go
浏览文件 @
8f24d8e2
...
@@ -18,7 +18,6 @@ import (
...
@@ -18,7 +18,6 @@ import (
corehttp
"github.com/ipfs/go-ipfs/core/corehttp"
corehttp
"github.com/ipfs/go-ipfs/core/corehttp"
corerepo
"github.com/ipfs/go-ipfs/core/corerepo"
corerepo
"github.com/ipfs/go-ipfs/core/corerepo"
nodeMount
"github.com/ipfs/go-ipfs/fuse/node"
nodeMount
"github.com/ipfs/go-ipfs/fuse/node"
//config "github.com/ipfs/go-ipfs/repo/config"
fsrepo
"github.com/ipfs/go-ipfs/repo/fsrepo"
fsrepo
"github.com/ipfs/go-ipfs/repo/fsrepo"
migrate
"github.com/ipfs/go-ipfs/repo/fsrepo/migrations"
migrate
"github.com/ipfs/go-ipfs/repo/fsrepo/migrations"
...
@@ -200,7 +199,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env interface{}) {
...
@@ -200,7 +199,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env interface{}) {
}
}
}
}
ctx
:=
env
.
(
*
oldcmds
.
Context
)
c
c
tx
:=
env
.
(
*
oldcmds
.
Context
)
go
func
()
{
go
func
()
{
<-
req
.
Context
.
Done
()
<-
req
.
Context
.
Done
()
...
@@ -219,10 +218,9 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env interface{}) {
...
@@ -219,10 +218,9 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env interface{}) {
// first, whether user has provided the initialization flag. we may be
// first, whether user has provided the initialization flag. we may be
// running in an uninitialized state.
// running in an uninitialized state.
initialize
,
_
:=
req
.
Options
[
initOptionKwd
]
.
(
bool
)
initialize
,
_
:=
req
.
Options
[
initOptionKwd
]
.
(
bool
)
if
initialize
{
if
initialize
{
cfg
:=
ctx
.
ConfigRoot
cfg
:=
c
c
tx
.
ConfigRoot
if
!
fsrepo
.
IsInitialized
(
cfg
)
{
if
!
fsrepo
.
IsInitialized
(
cfg
)
{
err
:=
initWithDefaults
(
os
.
Stdout
,
cfg
)
err
:=
initWithDefaults
(
os
.
Stdout
,
cfg
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -234,7 +232,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env interface{}) {
...
@@ -234,7 +232,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env interface{}) {
// acquire the repo lock _before_ constructing a node. we need to make
// acquire the repo lock _before_ constructing a node. we need to make
// sure we are permitted to access the resources (datastore, etc.)
// sure we are permitted to access the resources (datastore, etc.)
repo
,
err
:=
fsrepo
.
Open
(
ctx
.
ConfigRoot
)
repo
,
err
:=
fsrepo
.
Open
(
c
c
tx
.
ConfigRoot
)
switch
err
{
switch
err
{
default
:
default
:
re
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
re
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
...
@@ -264,7 +262,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env interface{}) {
...
@@ -264,7 +262,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env interface{}) {
return
return
}
}
repo
,
err
=
fsrepo
.
Open
(
ctx
.
ConfigRoot
)
repo
,
err
=
fsrepo
.
Open
(
c
c
tx
.
ConfigRoot
)
if
err
!=
nil
{
if
err
!=
nil
{
re
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
re
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
return
return
...
@@ -273,7 +271,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env interface{}) {
...
@@ -273,7 +271,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env interface{}) {
break
break
}
}
cfg
,
err
:=
ctx
.
GetConfig
()
cfg
,
err
:=
c
c
tx
.
GetConfig
()
if
err
!=
nil
{
if
err
!=
nil
{
re
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
re
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
return
return
...
@@ -340,12 +338,12 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env interface{}) {
...
@@ -340,12 +338,12 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env interface{}) {
}
}
}()
}()
ctx
.
ConstructNode
=
func
()
(
*
core
.
IpfsNode
,
error
)
{
c
c
tx
.
ConstructNode
=
func
()
(
*
core
.
IpfsNode
,
error
)
{
return
node
,
nil
return
node
,
nil
}
}
// construct api endpoint - every time
// construct api endpoint - every time
err
,
apiErrc
:=
serveHTTPApi
(
req
,
ctx
)
err
,
apiErrc
:=
serveHTTPApi
(
req
,
c
c
tx
)
if
err
!=
nil
{
if
err
!=
nil
{
re
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
re
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
return
return
...
@@ -359,7 +357,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env interface{}) {
...
@@ -359,7 +357,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env interface{}) {
return
return
}
}
if
mount
{
if
mount
{
if
err
:=
mountFuse
(
req
,
ctx
);
err
!=
nil
{
if
err
:=
mountFuse
(
req
,
c
c
tx
);
err
!=
nil
{
re
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
re
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
return
return
}
}
...
@@ -376,7 +374,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env interface{}) {
...
@@ -376,7 +374,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env interface{}) {
var
gwErrc
<-
chan
error
var
gwErrc
<-
chan
error
if
len
(
cfg
.
Addresses
.
Gateway
)
>
0
{
if
len
(
cfg
.
Addresses
.
Gateway
)
>
0
{
var
err
error
var
err
error
err
,
gwErrc
=
serveHTTPGateway
(
req
,
ctx
)
err
,
gwErrc
=
serveHTTPGateway
(
req
,
c
c
tx
)
if
err
!=
nil
{
if
err
!=
nil
{
re
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
re
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
return
return
...
...
cmd/ipfs/main.go
浏览文件 @
8f24d8e2
...
@@ -108,11 +108,8 @@ func mainRet() int {
...
@@ -108,11 +108,8 @@ func mainRet() int {
}
}
log
.
Debugf
(
"config path is %s"
,
repoPath
)
log
.
Debugf
(
"config path is %s"
,
repoPath
)
// this sets up the function that will initialize the config lazily.
// this sets up the function that will initialize the node
// this sets up the function that will initialize the node
// this is so that we can construct the node lazily.
// this is so that we can construct the node lazily.
return
&
oldcmds
.
Context
{
return
&
oldcmds
.
Context
{
ConfigRoot
:
repoPath
,
ConfigRoot
:
repoPath
,
LoadConfig
:
loadConfig
,
LoadConfig
:
loadConfig
,
...
...
commands/legacy/legacy.go
浏览文件 @
8f24d8e2
...
@@ -53,29 +53,3 @@ func OldContext(env interface{}) *oldcmds.Context {
...
@@ -53,29 +53,3 @@ func OldContext(env interface{}) *oldcmds.Context {
return
ctx
return
ctx
}
}
/*
// OldReqLog returns an oldcmds.ReqLog from a ReqLog
func OldReqLog(newrl *ReqLog) *oldcmds.ReqLog {
if newrl == nil {
return nil
}
rl := &oldcmds.ReqLog{}
for _, rle := range newrl.Requests {
oldrle := &oldcmds.ReqLogEntry{
StartTime: rle.StartTime,
EndTime: rle.EndTime,
Active: rle.Active,
Command: rle.Command,
Options: rle.Options,
Args: rle.Args,
ID: rle.ID,
}
rl.AddEntry(oldrle)
}
return rl
}
*/
commands/legacy/legacy_test.go
浏览文件 @
8f24d8e2
...
@@ -184,32 +184,3 @@ func TestTeeEmitter(t *testing.T) {
...
@@ -184,32 +184,3 @@ func TestTeeEmitter(t *testing.T) {
t
.
Fatal
(
"expected %#v, got %#v"
,
expect
,
buf2
.
String
())
t
.
Fatal
(
"expected %#v, got %#v"
,
expect
,
buf2
.
String
())
}
}
}
}
/*
type teeErrorTestCase struct {
err1, err2 error
bothNil bool
errString string
}
func TestTeeError(t *testing.T) {
tcs := []teeErrorTestCase{
teeErrorTestCase{nil, nil, true, ""},
teeErrorTestCase{fmt.Errorf("error!"), nil, false, "1: error!"},
teeErrorTestCase{nil, fmt.Errorf("error!"), false, "2: error!"},
teeErrorTestCase{fmt.Errorf("error!"), fmt.Errorf("error!"), false, `1: error!
2: error!`},
}
for i, tc := range tcs {
teeError := cmds.TeeError{tc.err1, tc.err2}
if teeError.BothNil() != tc.bothNil {
t.Fatalf("BothNil()/%d: expected %v but got %v", i, tc.bothNil, teeError.BothNil())
}
if teeError.Error() != tc.errString {
t.Fatalf("Error()/%d: expected %v but got %v", i, tc.errString, teeError.Error())
}
}
}
*/
commands/request.go
浏览文件 @
8f24d8e2
...
@@ -76,6 +76,9 @@ func (c *Context) RootContext() context.Context {
...
@@ -76,6 +76,9 @@ func (c *Context) RootContext() context.Context {
return
n
.
Context
()
return
n
.
Context
()
}
}
// LogRequest adds the passed request to the request log and
// returns a function that should be called when the request
// lifetime is over.
func
(
c
*
Context
)
LogRequest
(
req
*
cmds
.
Request
)
func
()
{
func
(
c
*
Context
)
LogRequest
(
req
*
cmds
.
Request
)
func
()
{
rle
:=
&
ReqLogEntry
{
rle
:=
&
ReqLogEntry
{
StartTime
:
time
.
Now
(),
StartTime
:
time
.
Now
(),
...
@@ -93,6 +96,7 @@ func (c *Context) LogRequest(req *cmds.Request) func() {
...
@@ -93,6 +96,7 @@ func (c *Context) LogRequest(req *cmds.Request) func() {
}
}
}
}
// Close cleans up the application state.
func
(
c
*
Context
)
Close
()
{
func
(
c
*
Context
)
Close
()
{
// let's not forget teardown. If a node was initialized, we must close it.
// let's not forget teardown. If a node was initialized, we must close it.
// Note that this means the underlying req.Context().Node variable is exposed.
// Note that this means the underlying req.Context().Node variable is exposed.
...
...
core/commands/add.go
浏览文件 @
8f24d8e2
...
@@ -145,6 +145,7 @@ You can now check what blocks have been created by:
...
@@ -145,6 +145,7 @@ You can now check what blocks have been created by:
return
nil
return
nil
}
}
// HACK! Using context to pass the size to PostRun
sizeCh
:=
make
(
chan
int64
,
1
)
sizeCh
:=
make
(
chan
int64
,
1
)
req
.
Context
=
context
.
WithValue
(
req
.
Context
,
"size"
,
sizeCh
)
req
.
Context
=
context
.
WithValue
(
req
.
Context
,
"size"
,
sizeCh
)
...
@@ -366,6 +367,7 @@ You can now check what blocks have been created by:
...
@@ -366,6 +367,7 @@ You can now check what blocks have been created by:
bar
.
Start
()
bar
.
Start
()
}
}
// HACK! using context to pass size from PreRun
var
sizeChan
chan
int64
var
sizeChan
chan
int64
sizeChan
,
_
=
req
.
Context
.
Value
(
"size"
)
.
(
chan
int64
)
sizeChan
,
_
=
req
.
Context
.
Value
(
"size"
)
.
(
chan
int64
)
...
@@ -429,7 +431,7 @@ You can now check what blocks have been created by:
...
@@ -429,7 +431,7 @@ You can now check what blocks have been created by:
bar
.
ShowTimeLeft
=
true
bar
.
ShowTimeLeft
=
true
}
}
case
<-
req
.
Context
.
Done
()
:
case
<-
req
.
Context
.
Done
()
:
//
re.SetError(req.Context.Err(), cmdkit.ErrNormal)
//
don't set or print error here, that happens in the goroutine below
return
return
}
}
}
}
...
...
core/commands/cat.go
浏览文件 @
8f24d8e2
...
@@ -62,7 +62,7 @@ var CatCmd = &cmds.Command{
...
@@ -62,7 +62,7 @@ var CatCmd = &cmds.Command{
}
}
err
=
req
.
ParseBodyArgs
()
err
=
req
.
ParseBodyArgs
()
if
err
!=
nil
&&
err
.
Error
()
!=
"all arguments covered by positional arguments"
{
if
err
!=
nil
&&
!
cmds
.
IsAllArgsAlreadyCovered
(
err
)
{
res
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
res
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
return
return
}
}
...
...
core/commands/commands.go
浏览文件 @
8f24d8e2
...
@@ -11,7 +11,6 @@ import (
...
@@ -11,7 +11,6 @@ import (
"sort"
"sort"
"strings"
"strings"
// oldcmds "github.com/ipfs/go-ipfs/commands"
e
"github.com/ipfs/go-ipfs/core/commands/e"
e
"github.com/ipfs/go-ipfs/core/commands/e"
"gx/ipfs/QmSRaAPPNxyhnXeDa5NXtZ2CWBYJ6BRWNQp6gKxhPcoqDM/go-ipfs-cmdkit"
"gx/ipfs/QmSRaAPPNxyhnXeDa5NXtZ2CWBYJ6BRWNQp6gKxhPcoqDM/go-ipfs-cmdkit"
...
...
core/commands/get_test.go
浏览文件 @
8f24d8e2
...
@@ -45,12 +45,10 @@ func TestGetOutputPath(t *testing.T) {
...
@@ -45,12 +45,10 @@ func TestGetOutputPath(t *testing.T) {
},
},
}
}
/*
_
,
err
:=
GetCmd
.
GetOptions
([]
string
{})
defOpts, err := GetCmd.GetOptions([]string{})
if
err
!=
nil
{
if err != nil {
t
.
Fatalf
(
"error getting default command options: %v"
,
err
)
t.Fatalf("error getting default command options: %v", err)
}
}
*/
for
_
,
tc
:=
range
cases
{
for
_
,
tc
:=
range
cases
{
req
,
err
:=
cmds
.
NewRequest
(
context
.
TODO
(),
[]
string
{},
tc
.
opts
,
tc
.
args
,
nil
,
GetCmd
)
req
,
err
:=
cmds
.
NewRequest
(
context
.
TODO
(),
[]
string
{},
tc
.
opts
,
tc
.
args
,
nil
,
GetCmd
)
...
...
test/sharness/t0110-gateway.sh
浏览文件 @
8f24d8e2
...
@@ -135,7 +135,7 @@ test_expect_success "get IPFS directory file through readonly API output looks g
...
@@ -135,7 +135,7 @@ test_expect_success "get IPFS directory file through readonly API output looks g
test_cmp dir/test actual
test_cmp dir/test actual
'
'
test_expect_
failure
"refs IPFS directory file through readonly API succeeds"
'
test_expect_
success
"refs IPFS directory file through readonly API succeeds"
'
test_curl_gateway_api "refs?arg=$HASH2/test"
test_curl_gateway_api "refs?arg=$HASH2/test"
'
'
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论