Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
5d8e1504
提交
5d8e1504
authored
8月 17, 2015
作者:
rht
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replace WithTimeout with WithCancel whenever possible
License: MIT Signed-off-by:
rht
<
rhtbot@gmail.com
>
上级
d32177cd
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
12 行增加
和
23 行删除
+12
-23
ls.go
core/commands/ls.go
+1
-2
ls.go
core/commands/unixfs/ls.go
+1
-2
core.go
core/core.go
+1
-2
pinning.go
core/corerepo/pinning.go
+2
-3
add.go
core/coreunix/add.go
+1
-2
metadata.go
core/coreunix/metadata.go
+2
-4
common.go
fuse/ipns/common.go
+1
-3
dir.go
ipnsfs/dir.go
+1
-2
resolver.go
path/resolver.go
+1
-1
dagmodifier.go
unixfs/mod/dagmodifier.go
+1
-2
没有找到文件。
core/commands/ls.go
浏览文件 @
5d8e1504
...
@@ -5,7 +5,6 @@ import (
...
@@ -5,7 +5,6 @@ import (
"fmt"
"fmt"
"io"
"io"
"text/tabwriter"
"text/tabwriter"
"time"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
...
@@ -81,7 +80,7 @@ it contains, with the following format:
...
@@ -81,7 +80,7 @@ it contains, with the following format:
Links
:
make
([]
LsLink
,
len
(
dagnode
.
Links
)),
Links
:
make
([]
LsLink
,
len
(
dagnode
.
Links
)),
}
}
for
j
,
link
:=
range
dagnode
.
Links
{
for
j
,
link
:=
range
dagnode
.
Links
{
ctx
,
cancel
:=
context
.
With
Timeout
(
req
.
Context
(),
time
.
Minute
)
ctx
,
cancel
:=
context
.
With
Cancel
(
req
.
Context
()
)
defer
cancel
()
defer
cancel
()
link
.
Node
,
err
=
link
.
GetNode
(
ctx
,
node
.
DAG
)
link
.
Node
,
err
=
link
.
GetNode
(
ctx
,
node
.
DAG
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
core/commands/unixfs/ls.go
浏览文件 @
5d8e1504
...
@@ -6,7 +6,6 @@ import (
...
@@ -6,7 +6,6 @@ import (
"io"
"io"
"sort"
"sort"
"text/tabwriter"
"text/tabwriter"
"time"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
...
@@ -111,7 +110,7 @@ size is the IPFS link size.
...
@@ -111,7 +110,7 @@ size is the IPFS link size.
links
:=
make
([]
LsLink
,
len
(
merkleNode
.
Links
))
links
:=
make
([]
LsLink
,
len
(
merkleNode
.
Links
))
output
.
Objects
[
hash
]
.
Links
=
links
output
.
Objects
[
hash
]
.
Links
=
links
for
i
,
link
:=
range
merkleNode
.
Links
{
for
i
,
link
:=
range
merkleNode
.
Links
{
getCtx
,
cancel
:=
context
.
With
Timeout
(
ctx
,
time
.
Minute
)
getCtx
,
cancel
:=
context
.
With
Cancel
(
ctx
)
defer
cancel
()
defer
cancel
()
link
.
Node
,
err
=
link
.
GetNode
(
getCtx
,
node
.
DAG
)
link
.
Node
,
err
=
link
.
GetNode
(
getCtx
,
node
.
DAG
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
core/core.go
浏览文件 @
5d8e1504
...
@@ -321,8 +321,7 @@ func setupDiscoveryOption(d config.Discovery) DiscoveryOption {
...
@@ -321,8 +321,7 @@ func setupDiscoveryOption(d config.Discovery) DiscoveryOption {
func
(
n
*
IpfsNode
)
HandlePeerFound
(
p
peer
.
PeerInfo
)
{
func
(
n
*
IpfsNode
)
HandlePeerFound
(
p
peer
.
PeerInfo
)
{
log
.
Warning
(
"trying peer info: "
,
p
)
log
.
Warning
(
"trying peer info: "
,
p
)
ctx
,
_
:=
context
.
WithTimeout
(
n
.
Context
(),
time
.
Second
*
10
)
ctx
,
_
:=
context
.
WithTimeout
(
n
.
Context
(),
time
.
Second
*
10
)
err
:=
n
.
PeerHost
.
Connect
(
ctx
,
p
)
if
err
:=
n
.
PeerHost
.
Connect
(
ctx
,
p
);
err
!=
nil
{
if
err
!=
nil
{
log
.
Warning
(
"Failed to connect to peer found by discovery: "
,
err
)
log
.
Warning
(
"Failed to connect to peer found by discovery: "
,
err
)
}
}
}
}
...
...
core/corerepo/pinning.go
浏览文件 @
5d8e1504
...
@@ -15,7 +15,6 @@ package corerepo
...
@@ -15,7 +15,6 @@ package corerepo
import
(
import
(
"fmt"
"fmt"
"time"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
...
@@ -42,7 +41,7 @@ func Pin(n *core.IpfsNode, ctx context.Context, paths []string, recursive bool)
...
@@ -42,7 +41,7 @@ func Pin(n *core.IpfsNode, ctx context.Context, paths []string, recursive bool)
return
nil
,
err
return
nil
,
err
}
}
ctx
,
cancel
:=
context
.
With
Timeout
(
ctx
,
time
.
Minute
)
ctx
,
cancel
:=
context
.
With
Cancel
(
ctx
)
defer
cancel
()
defer
cancel
()
err
=
n
.
Pinning
.
Pin
(
ctx
,
dagnode
,
recursive
)
err
=
n
.
Pinning
.
Pin
(
ctx
,
dagnode
,
recursive
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -74,7 +73,7 @@ func Unpin(n *core.IpfsNode, ctx context.Context, paths []string, recursive bool
...
@@ -74,7 +73,7 @@ func Unpin(n *core.IpfsNode, ctx context.Context, paths []string, recursive bool
for
_
,
dagnode
:=
range
dagnodes
{
for
_
,
dagnode
:=
range
dagnodes
{
k
,
_
:=
dagnode
.
Key
()
k
,
_
:=
dagnode
.
Key
()
ctx
,
cancel
:=
context
.
With
Timeout
(
ctx
,
time
.
Minute
)
ctx
,
cancel
:=
context
.
With
Cancel
(
ctx
)
defer
cancel
()
defer
cancel
()
err
:=
n
.
Pinning
.
Unpin
(
ctx
,
k
,
recursive
)
err
:=
n
.
Pinning
.
Unpin
(
ctx
,
k
,
recursive
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
core/coreunix/add.go
浏览文件 @
5d8e1504
...
@@ -5,7 +5,6 @@ import (
...
@@ -5,7 +5,6 @@ import (
"io/ioutil"
"io/ioutil"
"os"
"os"
gopath
"path"
gopath
"path"
"time"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
...
@@ -105,7 +104,7 @@ func addNode(n *core.IpfsNode, node *merkledag.Node) error {
...
@@ -105,7 +104,7 @@ func addNode(n *core.IpfsNode, node *merkledag.Node) error {
if
err
:=
n
.
DAG
.
AddRecursive
(
node
);
err
!=
nil
{
// add the file to the graph + local storage
if
err
:=
n
.
DAG
.
AddRecursive
(
node
);
err
!=
nil
{
// add the file to the graph + local storage
return
err
return
err
}
}
ctx
,
cancel
:=
context
.
With
Timeout
(
n
.
Context
(),
time
.
Minute
)
ctx
,
cancel
:=
context
.
With
Cancel
(
n
.
Context
()
)
defer
cancel
()
defer
cancel
()
err
:=
n
.
Pinning
.
Pin
(
ctx
,
node
,
true
)
// ensure we keep it
err
:=
n
.
Pinning
.
Pin
(
ctx
,
node
,
true
)
// ensure we keep it
return
err
return
err
...
...
core/coreunix/metadata.go
浏览文件 @
5d8e1504
package
coreunix
package
coreunix
import
(
import
(
"time"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
key
"github.com/ipfs/go-ipfs/blocks/key"
key
"github.com/ipfs/go-ipfs/blocks/key"
...
@@ -14,7 +12,7 @@ import (
...
@@ -14,7 +12,7 @@ import (
func
AddMetadataTo
(
n
*
core
.
IpfsNode
,
skey
string
,
m
*
ft
.
Metadata
)
(
string
,
error
)
{
func
AddMetadataTo
(
n
*
core
.
IpfsNode
,
skey
string
,
m
*
ft
.
Metadata
)
(
string
,
error
)
{
ukey
:=
key
.
B58KeyDecode
(
skey
)
ukey
:=
key
.
B58KeyDecode
(
skey
)
ctx
,
cancel
:=
context
.
With
Timeout
(
n
.
Context
(),
time
.
Minute
)
ctx
,
cancel
:=
context
.
With
Cancel
(
n
.
Context
()
)
defer
cancel
()
defer
cancel
()
nd
,
err
:=
n
.
DAG
.
Get
(
ctx
,
ukey
)
nd
,
err
:=
n
.
DAG
.
Get
(
ctx
,
ukey
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -44,7 +42,7 @@ func AddMetadataTo(n *core.IpfsNode, skey string, m *ft.Metadata) (string, error
...
@@ -44,7 +42,7 @@ func AddMetadataTo(n *core.IpfsNode, skey string, m *ft.Metadata) (string, error
func
Metadata
(
n
*
core
.
IpfsNode
,
skey
string
)
(
*
ft
.
Metadata
,
error
)
{
func
Metadata
(
n
*
core
.
IpfsNode
,
skey
string
)
(
*
ft
.
Metadata
,
error
)
{
ukey
:=
key
.
B58KeyDecode
(
skey
)
ukey
:=
key
.
B58KeyDecode
(
skey
)
ctx
,
cancel
:=
context
.
With
Timeout
(
n
.
Context
(),
time
.
Minute
)
ctx
,
cancel
:=
context
.
With
Cancel
(
n
.
Context
()
)
defer
cancel
()
defer
cancel
()
nd
,
err
:=
n
.
DAG
.
Get
(
ctx
,
ukey
)
nd
,
err
:=
n
.
DAG
.
Get
(
ctx
,
ukey
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
fuse/ipns/common.go
浏览文件 @
5d8e1504
package
ipns
package
ipns
import
(
import
(
"time"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
"github.com/ipfs/go-ipfs/core"
"github.com/ipfs/go-ipfs/core"
...
@@ -22,7 +20,7 @@ func InitializeKeyspace(n *core.IpfsNode, key ci.PrivKey) error {
...
@@ -22,7 +20,7 @@ func InitializeKeyspace(n *core.IpfsNode, key ci.PrivKey) error {
return
err
return
err
}
}
ctx
,
cancel
:=
context
.
With
Timeout
(
n
.
Context
(),
time
.
Minute
)
ctx
,
cancel
:=
context
.
With
Cancel
(
n
.
Context
()
)
defer
cancel
()
defer
cancel
()
err
=
n
.
Pinning
.
Pin
(
ctx
,
emptyDir
,
false
)
err
=
n
.
Pinning
.
Pin
(
ctx
,
emptyDir
,
false
)
...
...
ipnsfs/dir.go
浏览文件 @
5d8e1504
...
@@ -5,7 +5,6 @@ import (
...
@@ -5,7 +5,6 @@ import (
"fmt"
"fmt"
"os"
"os"
"sync"
"sync"
"time"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
...
@@ -140,7 +139,7 @@ func (d *Directory) childDir(name string) (*Directory, error) {
...
@@ -140,7 +139,7 @@ func (d *Directory) childDir(name string) (*Directory, error) {
func
(
d
*
Directory
)
childFromDag
(
name
string
)
(
*
dag
.
Node
,
error
)
{
func
(
d
*
Directory
)
childFromDag
(
name
string
)
(
*
dag
.
Node
,
error
)
{
for
_
,
lnk
:=
range
d
.
node
.
Links
{
for
_
,
lnk
:=
range
d
.
node
.
Links
{
if
lnk
.
Name
==
name
{
if
lnk
.
Name
==
name
{
ctx
,
cancel
:=
context
.
With
Timeout
(
d
.
ctx
,
time
.
Minute
)
ctx
,
cancel
:=
context
.
With
Cancel
(
d
.
ctx
)
defer
cancel
()
defer
cancel
()
return
lnk
.
GetNode
(
ctx
,
d
.
fs
.
dserv
)
return
lnk
.
GetNode
(
ctx
,
d
.
fs
.
dserv
)
...
...
path/resolver.go
浏览文件 @
5d8e1504
...
@@ -87,7 +87,7 @@ func (s *Resolver) ResolvePathComponents(ctx context.Context, fpath Path) ([]*me
...
@@ -87,7 +87,7 @@ func (s *Resolver) ResolvePathComponents(ctx context.Context, fpath Path) ([]*me
}
}
log
.
Debug
(
"Resolve dag get."
)
log
.
Debug
(
"Resolve dag get."
)
ctx
,
cancel
:=
context
.
With
Timeout
(
ctx
,
time
.
Minute
)
ctx
,
cancel
:=
context
.
With
Cancel
(
ctx
)
defer
cancel
()
defer
cancel
()
nd
,
err
:=
s
.
DAG
.
Get
(
ctx
,
key
.
Key
(
h
))
nd
,
err
:=
s
.
DAG
.
Get
(
ctx
,
key
.
Key
(
h
))
if
err
!=
nil
{
if
err
!=
nil
{
...
...
unixfs/mod/dagmodifier.go
浏览文件 @
5d8e1504
...
@@ -5,7 +5,6 @@ import (
...
@@ -5,7 +5,6 @@ import (
"errors"
"errors"
"io"
"io"
"os"
"os"
"time"
proto
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
proto
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
mh
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
mh
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
...
@@ -460,7 +459,7 @@ func dagTruncate(ctx context.Context, nd *mdag.Node, size uint64, ds mdag.DAGSer
...
@@ -460,7 +459,7 @@ func dagTruncate(ctx context.Context, nd *mdag.Node, size uint64, ds mdag.DAGSer
var
modified
*
mdag
.
Node
var
modified
*
mdag
.
Node
ndata
:=
new
(
ft
.
FSNode
)
ndata
:=
new
(
ft
.
FSNode
)
for
i
,
lnk
:=
range
nd
.
Links
{
for
i
,
lnk
:=
range
nd
.
Links
{
_ctx
,
cancel
:=
context
.
With
Timeout
(
ctx
,
time
.
Minute
)
_ctx
,
cancel
:=
context
.
With
Cancel
(
ctx
)
defer
cancel
()
defer
cancel
()
child
,
err
:=
lnk
.
GetNode
(
ctx
,
ds
)
child
,
err
:=
lnk
.
GetNode
(
ctx
,
ds
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论