Skip to content

Commit

Permalink
refactor(commands): cleanup makeDagNodeLinkResults
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: hannahhoward <hannah@hannahhoward.net>
  • Loading branch information
hannahhoward committed Nov 19, 2018
1 parent b0dc73c commit 0a5b1a2
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions core/commands/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,14 @@ The JSON output contains type information.
}

func makeDagNodeLinkResults(req *cmds.Request, dagnode ipld.Node) <-chan unixfs.LinkResult {
linkResults := make(chan unixfs.LinkResult)
go func() {
defer close(linkResults)
for _, l := range dagnode.Links() {
select {
case linkResults <- unixfs.LinkResult{
Link: l,
Err: nil,
}:
case <-req.Context.Done():
return
}
links := dagnode.Links()
linkResults := make(chan unixfs.LinkResult, len(links))
for _, l := range links {
linkResults <- unixfs.LinkResult{
Link: l,
Err: nil,
}
}()
}
return linkResults
}

Expand Down

0 comments on commit 0a5b1a2

Please sign in to comment.