-
-
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
improve gateway symlink handling #6680
Conversation
829d639
to
80e0c47
Compare
func (s *lazySeeker) Seek(offset int64, whence int) (int64, error) { | ||
switch whence { | ||
case io.SeekEnd: | ||
return s.Seek(s.size+offset, io.SeekStart) |
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.
isn't it s.size-offset
?
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.
If we're seeking from the end, the offset will already be negative.
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.
Actually, this was wrong. It should have been Nvm. Seeking to the end is correctly done with a s.size-1+offset
.Seek(-1, SeekEnd)
.
Build and tested with commit 361bb5f. |
18d1ab2
to
7a8e04e
Compare
7a8e04e
to
76b943b
Compare
76b943b
to
6f1204d
Compare
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 nit, but otherwise the code LGTM. May be worth adding some tests for the different kinds of Seek()
Thanks for catching that (and bugging me to write a test)! |
(ok, there's definitely a bug here, I'll look into it when I get a chance) |
Fixes symlink sizes.
1. Require files to have known sizes. We can add support for unknown sizes _later_ but we can't use ServeContent for those files. 2. Replace the `sizeReadSeeker` with a `lazySeeker`. This one makes no assumptions about how it's used so we're less likely to run into weird bugs.
We should be _resolving_ symlinks (sometimes, still need to figure out when to do this WRT IPNS). However, that's a larger feature.
fe26806
to
c64eb11
Compare
improve gateway symlink handling This commit was moved from ipfs/kubo@ca2767a
Note: This doesn't provide actual symlink support. The gateway treats symlinks
like text files.
fixes #6203