-
Notifications
You must be signed in to change notification settings - Fork 657
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
api: getReaderSize() should honor seeked file descriptors. #681
Conversation
e6465d3
to
b8b7560
Compare
26457ec
to
8a3d9a1
Compare
8a3d9a1
to
e0b6cd0
Compare
e0b6cd0
to
d92c6cf
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.
The changes look good to me, I have a few comments on unit test.
api_functional_v4_test.go
Outdated
t.Fatal("Error:", err) | ||
} | ||
|
||
objectName := fmt.Sprintf("test-file-%v", rand.Uint32()) |
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.
Why does objectName
need a random suffix?
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.
Just for uniqueness.. Each test needs to be self contained and not overwrite each other with generic names.
if err != nil { | ||
t.Fatal("Error:", 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.
Why can't we write data
here instead of closing and using io.WriteFile
which would do its own Open
and Close
?
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.
We can.. let me add that.
api_functional_v4_test.go
Outdated
|
||
objectName := fmt.Sprintf("test-file-%v", rand.Uint32()) | ||
|
||
offset := 123 |
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.
Suggestion: we could have offset
as length/2
(say). This ensures that offset would be valid independent of the length
we choose. Having offset
as an independent constant allows for situations in the future where offset
may be greater than length
etc. We have seen similar cases with our unit tests in the past, e.g index 13
was used to access a variably sized buffer.
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.
When would that happen in this case? this is a self contained test. But it is do-able to just do length/2.
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.
There is no issue with this PR. It is possible that constants for length
and offset
may be changed independently leading to an invalid test case accidentally. So, this is only a suggestion.
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.
Fixed.
d92c6cf
to
ab6126a
Compare
In situations where a file has been Seeked, we need to start reading from the offset which it indeed happens. But our reader size calculation needs to honor this to be accurate. Fixes minio#680
ab6126a
to
cc83645
Compare
In situations where a file has been Seeked, we need to
start reading from the offset which it indeed happens.
But our reader size calculation needs to honor this to
be accurate.
Fixes #680