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

Use HeadObject for statRequest #16

Merged
merged 1 commit into from
Apr 30, 2020
Merged

Conversation

jcharum
Copy link
Contributor

@jcharum jcharum commented Apr 30, 2020

Use HeadObject instead of GetObject for handling statRequests. Besides being a better semantic match, it fixes #15.

Copy link
Contributor

@josh-newman josh-newman left a comment

Choose a reason for hiding this comment

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

Does startGetObjectRequest still need to construct newInfo?

@jcharum
Copy link
Contributor Author

jcharum commented Apr 30, 2020

Does startGetObjectRequest still need to construct newInfo?

I don't think so, but I'm only 80% sure, as I have little experience with this code. My reasoning goes like this:

  1. startGetObjectRequest will only call newInfo if f.info == nil.
  2. startGetObjectRequest is only called by handleRead.
  3. handleRead is only called to handle a readRequest.
  4. readRequest is only issued in (*s3Reader).Read.
  5. The only way to get an *s3Reader is by (*s3File).Reader. It only does this if f.mode == readonly.
  6. The only way to get a readonly *s3File is by (*s3Impl).Open.
  7. (*s3Impl).Open will only return successfully if the handleStat sends a non-error response, via runRequest and statRequest.
  8. handleStat only sends a non-error response after populating f.info.
  9. Therefore, f.info != nil in startGetObjectRequest, and it will not call newInfo.

I'm not really sure how to thoroughly test removal of this code right now, so I don't want to add it to this PR. The change in this PR seems much less risky.

Also, I looked through the history, and I think the f.info == nil case became obsolete in 3cf2bd3, which introduced the statRequest on (*s3Impl).Open.

@jcharum jcharum merged commit 223f7ea into grailbio:master Apr 30, 2020
@jcharum jcharum mentioned this pull request Apr 30, 2020
@jcharum jcharum deleted the stat-head-object branch April 30, 2020 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(*s3File).Open panics opening file with Content-Encoding: gzip
3 participants