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

fix(storage): fix tellg() values #12844

Merged

Conversation

coryan
Copy link
Contributor

@coryan coryan commented Oct 7, 2023

The initial values for tellg() were incorrect ReadRange() and ReadLast() options.


This change is Reviewable

The initial values for `tellg()` were incorrect `ReadRange()` and
`ReadLast()` options.
@coryan coryan temporarily deployed to internal October 7, 2023 19:15 — with GitHub Actions Inactive
@product-auto-label product-auto-label bot added the api: storage Issues related to the Cloud Storage API. label Oct 7, 2023
@codecov
Copy link

codecov bot commented Oct 7, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (6380988) 93.55% compared to head (c258c6d) 93.55%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #12844   +/-   ##
=======================================
  Coverage   93.55%   93.55%           
=======================================
  Files        2074     2074           
  Lines      180452   180548   +96     
=======================================
+ Hits       168815   168911   +96     
  Misses      11637    11637           
Files Coverage Δ
google/cloud/storage/client.cc 85.48% <100.00%> (-0.05%) ⬇️
...le/cloud/storage/internal/object_read_streambuf.cc 99.06% <100.00%> (+0.07%) ⬆️
...gle/cloud/storage/internal/object_read_streambuf.h 100.00% <ø> (ø)
...oud/storage/internal/object_read_streambuf_test.cc 100.00% <100.00%> (ø)
...oud/storage/tests/object_media_integration_test.cc 98.82% <100.00%> (+0.05%) ⬆️

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@coryan coryan marked this pull request as ready for review October 7, 2023 20:50
@coryan coryan requested a review from a team as a code owner October 7, 2023 20:50
: source_(std::move(source)),
source_pos_(pos_in_stream),
source_pos_(static_cast<std::streamoff>(InitialOffset(request))),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to static cast to std::streamoff when it looks like InitialOffset() already returns a std::streamoff?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

D'oh! That is what happens when you refactor to a function and forget to clean up the call site.

if (source_pos_ >= 0) {
source_pos_ += static_cast<std::streamoff>(read->bytes_received);
} else if (size_) {
source_pos_ = *size_ + source_pos_ +
Copy link
Contributor

Choose a reason for hiding this comment

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

Use source_pos_ += ... too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@coryan coryan temporarily deployed to internal October 8, 2023 12:37 — with GitHub Actions Inactive
@coryan coryan enabled auto-merge (squash) October 8, 2023 12:39
@coryan coryan merged commit e3364f4 into googleapis:main Oct 8, 2023
@coryan coryan deleted the fix-storage-mitigate-bad-initial-tellg branch October 8, 2023 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants