Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipfs files ls without -l is faster #2007

Merged
merged 1 commit into from
Nov 26, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions core/commands/files/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,33 @@ Examples:
return
}

long, _, _ := req.Option("l").Bool()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be a proper argument? makes it appear in --help and also makes it easier to find the options this accepts, when reading the code

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right, this only reads the option, i mistook it for its definition


switch fsn := fsn.(type) {
case *mfs.Directory:
listing, err := fsn.List()
if err != nil {
res.SetError(err, cmds.ErrNormal)
return
if !long {
mdnd, err := fsn.GetNode()
if err != nil {
res.SetError(err, cmds.ErrNormal)
return
}

var output []mfs.NodeListing
for _, lnk := range mdnd.Links {
output = append(output, mfs.NodeListing{
Name: lnk.Name,
Hash: lnk.Hash.B58String(),
})
}
res.SetOutput(&FilesLsOutput{output})
} else {
listing, err := fsn.List()
if err != nil {
res.SetError(err, cmds.ErrNormal)
return
}
res.SetOutput(&FilesLsOutput{listing})
}
res.SetOutput(&FilesLsOutput{listing})
return
case *mfs.File:
parts := strings.Split(path, "/")
Expand Down