Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
cd2ac441
Commit
cd2ac441
authored
Aug 16, 2015
by
rht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure ctx in commands are derived from req.Context
License: MIT Signed-off-by:
rht
<
rhtbot@gmail.com
>
parent
c3db1bde
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
17 deletions
+6
-17
io/dirbuilder.go
io/dirbuilder.go
+2
-13
mod/dagmodifier.go
mod/dagmodifier.go
+4
-4
No files found.
io/dirbuilder.go
View file @
cd2ac441
package
io
import
(
"time"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
key
"github.com/ipfs/go-ipfs/blocks/key"
...
...
@@ -29,22 +27,13 @@ func NewDirectory(dserv mdag.DAGService) *directoryBuilder {
}
// AddChild adds a (name, key)-pair to the root node.
func
(
d
*
directoryBuilder
)
AddChild
(
name
string
,
k
key
.
Key
)
error
{
// TODO(cryptix): consolidate context managment
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
TODO
(),
time
.
Minute
)
defer
cancel
()
func
(
d
*
directoryBuilder
)
AddChild
(
ctx
context
.
Context
,
name
string
,
k
key
.
Key
)
error
{
cnode
,
err
:=
d
.
dserv
.
Get
(
ctx
,
k
)
if
err
!=
nil
{
return
err
}
err
=
d
.
dirnode
.
AddNodeLinkClean
(
name
,
cnode
)
if
err
!=
nil
{
return
err
}
return
nil
return
d
.
dirnode
.
AddNodeLinkClean
(
name
,
cnode
)
}
// GetNode returns the root of this directoryBuilder
...
...
mod/dagmodifier.go
View file @
cd2ac441
...
...
@@ -428,7 +428,7 @@ func (dm *DagModifier) Truncate(size int64) error {
return
dm
.
expandSparse
(
int64
(
size
)
-
realSize
)
}
nnode
,
err
:=
dagTruncate
(
dm
.
curNode
,
uint64
(
size
),
dm
.
dagserv
)
nnode
,
err
:=
dagTruncate
(
dm
.
ctx
,
dm
.
curNode
,
uint64
(
size
),
dm
.
dagserv
)
if
err
!=
nil
{
return
err
}
...
...
@@ -443,7 +443,7 @@ func (dm *DagModifier) Truncate(size int64) error {
}
// dagTruncate truncates the given node to 'size' and returns the modified Node
func
dagTruncate
(
nd
*
mdag
.
Node
,
size
uint64
,
ds
mdag
.
DAGService
)
(
*
mdag
.
Node
,
error
)
{
func
dagTruncate
(
ctx
context
.
Context
,
nd
*
mdag
.
Node
,
size
uint64
,
ds
mdag
.
DAGService
)
(
*
mdag
.
Node
,
error
)
{
if
len
(
nd
.
Links
)
==
0
{
// TODO: this can likely be done without marshaling and remarshaling
pbn
,
err
:=
ft
.
FromBytes
(
nd
.
Data
)
...
...
@@ -460,7 +460,7 @@ func dagTruncate(nd *mdag.Node, size uint64, ds mdag.DAGService) (*mdag.Node, er
var
modified
*
mdag
.
Node
ndata
:=
new
(
ft
.
FSNode
)
for
i
,
lnk
:=
range
nd
.
Links
{
ctx
,
cancel
:=
context
.
WithTimeout
(
c
ontext
.
TODO
()
,
time
.
Minute
)
_
ctx
,
cancel
:=
context
.
WithTimeout
(
c
tx
,
time
.
Minute
)
defer
cancel
()
child
,
err
:=
lnk
.
GetNode
(
ctx
,
ds
)
...
...
@@ -475,7 +475,7 @@ func dagTruncate(nd *mdag.Node, size uint64, ds mdag.DAGService) (*mdag.Node, er
// found the child we want to cut
if
size
<
cur
+
childsize
{
nchild
,
err
:=
dagTruncate
(
child
,
size
-
cur
,
ds
)
nchild
,
err
:=
dagTruncate
(
_ctx
,
child
,
size
-
cur
,
ds
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment