-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
improved gateway directory listing for sharded nodes #3897
Conversation
@@ -227,92 +229,102 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr | |||
return | |||
} | |||
|
|||
links, err := i.api.Unixfs().Ls(ctx, resolvedPath) | |||
nd, err := i.api.ResolveNode(ctx, resolvedPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we get the whole node here, we can meld this call and i.api.Unixfs().Cat(ctx, resolvedPath)
further above into one
I would love to get this reviewed ASAP so we can sneak it into 0.4.9. It makes viewing indexes in large directories on the gateway possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am still trying to figure out what this is doing. I think I know what is going on in core/commands/files/files.go
can you give me a one or two sentence overview of what you are doing in core/corehttp/gateway_handler.go
?
core/commands/files/files.go
Outdated
out.Size = d.GetFilesize() | ||
out.CumulativeSize = cumulsize | ||
|
||
case *dag.RawNode: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: There is a lot of code movement in this file. From what I can tell all that is really going on is there is an optimization for RawNode so that it doesn't have the get the block associated with the RawNode. Is this correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, yeah. Though im going to remove the changes to the files code from this PR. Its a separate changeset
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
ec8d9eb
to
5bb480b
Compare
Previously, to find if the directory had an index.html, we enumerated all the links, and iterated over them and looked for one named 'index.html'. That worked okay previously, but for large sharded directories, its realy slow. I've switched it to using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor style issue, but otherwise LGTM.
http.ServeContent(w, r, "index.html", modtime, dr) | ||
return | ||
default: | ||
internalWebError(w, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what the official go style is here, but I would put the default as the last case, although I have seen it as the first case in go code, just don't put in the middle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case it isn't about keyword but its meaning. In this case default
error is still an error, below it there is non-error handler.
improved gateway directory listing for sharded nodes This commit was moved from ipfs/kubo@afa0c34
License: MIT
Signed-off-by: Jeromy jeromyj@gmail.com