Skip to content

Commit b5b494b

Browse files
committed
fix the format
1 parent 7ef96f3 commit b5b494b

File tree

4 files changed

+54
-53
lines changed

4 files changed

+54
-53
lines changed

google/cloud/storage/internal/object_write_streambuf.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ void ObjectWriteStreambuf::FlushFinal() {
144144

145145
// Calculate the portion of the buffer that needs to be uploaded, if any.
146146
auto const actual_size = put_area_size();
147-
HashValues final_hashes = known_hashes_;
148-
if (hash_function_) {
149-
hash_function_->Update(committed_size_, {pbase(), actual_size});
150-
final_hashes = hash_function_->Finish();
151-
hash_function_.reset();
152-
}
147+
HashValues final_hashes = known_hashes_;
148+
if (hash_function_) {
149+
hash_function_->Update(committed_size_, {pbase(), actual_size});
150+
final_hashes = hash_function_->Finish();
151+
hash_function_.reset();
152+
}
153153

154154
// After this point the session will be closed, and no more calls to the hash
155155
// function are possible.
@@ -163,7 +163,7 @@ void ObjectWriteStreambuf::FlushFinal() {
163163
last_status_ = std::move(response).status();
164164
return;
165165
}
166-
hash_values_ = final_hashes;
166+
hash_values_ = final_hashes;
167167

168168
committed_size_ = response->committed_size.value_or(0);
169169
metadata_ = std::move(response->payload);

google/cloud/storage/internal/rest/stub.cc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -770,23 +770,23 @@ StatusOr<QueryResumableUploadResponse> RestStub::UploadChunk(
770770
// default (at least in this case), and that wastes bandwidth as the content
771771
// length is known.
772772
builder.AddHeader("Transfer-Encoding", {});
773-
auto hash_function = request.hash_function_ptr();
774-
if (hash_function) {
775-
auto offset = request.offset();
776-
for (auto const& b : request.payload()) {
777-
hash_function->Update(offset, absl::string_view{b.data(), b.size()});
778-
offset += b.size();
779-
}
780-
}
781-
if (request.last_chunk()) {
782-
auto const& hashes = request.known_object_hashes();
783-
if (!hashes.crc32c.empty()) {
784-
builder.AddHeader("x-goog-hash", "crc32c=" + hashes.crc32c);
785-
}
786-
if (!hashes.md5.empty()) {
787-
builder.AddHeader("x-goog-hash", "md5=" + hashes.md5);
788-
}
789-
}
773+
auto hash_function = request.hash_function_ptr();
774+
if (hash_function) {
775+
auto offset = request.offset();
776+
for (auto const& b : request.payload()) {
777+
hash_function->Update(offset, absl::string_view{b.data(), b.size()});
778+
offset += b.size();
779+
}
780+
}
781+
if (request.last_chunk()) {
782+
auto const& hashes = request.known_object_hashes();
783+
if (!hashes.crc32c.empty()) {
784+
builder.AddHeader("x-goog-hash", "crc32c=" + hashes.crc32c);
785+
}
786+
if (!hashes.md5.empty()) {
787+
builder.AddHeader("x-goog-hash", "md5=" + hashes.md5);
788+
}
789+
}
790790

791791
auto failure_predicate = [](rest::HttpStatusCode code) {
792792
return (code != rest::HttpStatusCode::kResumeIncomplete &&

google/cloud/storage/internal/rest/stub_test.cc

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,11 @@ class NoOpHashFunction : public HashFunction {
5454
Cormorant(o, b);
5555
return Status{};
5656
}
57-
Status Update(std::int64_t o, absl::string_view b,
58-
std::uint32_t c) override {
57+
Status Update(std::int64_t o, absl::string_view b, std::uint32_t c) override {
5958
Cormorant(o, b, c);
6059
return Status{};
6160
}
62-
Status Update(std::int64_t o, absl::Cord const& b,
63-
std::uint32_t c) override {
61+
Status Update(std::int64_t o, absl::Cord const& b, std::uint32_t c) override {
6462
Cormorant(o, b, c);
6563
return Status{};
6664
}
@@ -971,13 +969,14 @@ TEST(RestStubTest, UploadChunkLastChunkWithCrc32c) {
971969

972970
TEST(RestStubTest, UploadChunkLastChunkWithMd5) {
973971
auto mock = std::make_shared<MockRestClient>();
974-
EXPECT_CALL(*mock,
975-
Put(ExpectedContext(),
976-
ResultOf("request headers contain x-goog-hash with md5",
977-
[](RestRequest const& r) { return r.headers(); },
978-
Contains(Pair("x-goog-hash",
979-
ElementsAre("md5=test-md5")))),
980-
ExpectedPayload()))
972+
EXPECT_CALL(
973+
*mock,
974+
Put(ExpectedContext(),
975+
ResultOf(
976+
"request headers contain x-goog-hash with md5",
977+
[](RestRequest const& r) { return r.headers(); },
978+
Contains(Pair("x-goog-hash", ElementsAre("md5=test-md5")))),
979+
ExpectedPayload()))
981980
.WillOnce(Return(PermanentError()));
982981
auto tested = std::make_unique<RestStub>(Options{}, mock, mock);
983982
auto context = TestContext();
@@ -999,7 +998,7 @@ TEST(RestStubTest, UploadChunkLastChunkWithBoth) {
999998
"request headers contain x-goog-hash with crc32c and md5",
1000999
[](RestRequest const& r) { return r.headers(); },
10011000
Contains(Pair("x-goog-hash", ElementsAre("crc32c=test-crc32c",
1002-
"md5=test-md5")))),
1001+
"md5=test-md5")))),
10031002
ExpectedPayload()))
10041003
.WillOnce(Return(PermanentError()));
10051004
auto tested = std::make_unique<RestStub>(Options{}, mock, mock);
@@ -1016,9 +1015,10 @@ TEST(RestStubTest, UploadChunkLastChunkWithBoth) {
10161015
TEST(RestStubTest, UploadChunkIntermediate) {
10171016
auto mock = std::make_shared<MockRestClient>();
10181017
EXPECT_CALL(*mock, Put(ExpectedContext(),
1019-
ResultOf("request headers do not contain x-goog-hash",
1020-
[](RestRequest const& r) { return r.headers(); },
1021-
Not(Contains(Pair("x-goog-hash", _)))),
1018+
ResultOf(
1019+
"request headers do not contain x-goog-hash",
1020+
[](RestRequest const& r) { return r.headers(); },
1021+
Not(Contains(Pair("x-goog-hash", _)))),
10221022
ExpectedPayload()))
10231023
.WillOnce(Return(PermanentError()));
10241024
auto tested = std::make_unique<RestStub>(Options{}, mock, mock);

google/cloud/storage/tests/object_checksum_integration_test.cc

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ TEST_F(ObjectChecksumIntegrationTest, WriteObjectExplicitEnable) {
194194
EXPECT_THAT(os.computed_hash(),
195195
HasSubstr(ComputeCrc32cChecksum(LoremIpsum())));
196196
if (meta->has_metadata("x_emulator_upload")) {
197-
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_crc32c", _)));
198-
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_no_md5", _)));
197+
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_crc32c", _)));
198+
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_no_md5", _)));
199199
}
200200
}
201201

@@ -286,42 +286,44 @@ TEST_F(ObjectChecksumIntegrationTest, WriteObjectWithFullChecksumValidation) {
286286

287287
auto os = client.WriteObject(bucket_name_, object_name,
288288
DisableCrc32cChecksum(false),
289-
DisableMD5Hash(true),
290-
IfGenerationMatch(0));
289+
DisableMD5Hash(true), IfGenerationMatch(0));
291290
os << content;
292291
os.Close();
293292
auto meta = os.metadata();
294293
ASSERT_STATUS_OK(meta);
295294
ScheduleForDelete(*meta);
296295

297296
EXPECT_EQ(os.computed_hash(), expected_crc32c);
298-
297+
299298
if (meta->has_metadata("x_emulator_upload")) {
300-
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_crc32c", expected_crc32c)));
299+
EXPECT_THAT(meta->metadata(),
300+
Contains(Pair("x_emulator_crc32c", expected_crc32c)));
301301
EXPECT_THAT(meta->metadata(), Contains(Pair("x_emulator_no_md5", "true")));
302302
}
303303
}
304304

305-
/// @test Verify that the upload fails when the provided CRC32C checksum does not match the data.
305+
/// @test Verify that the upload fails when the provided CRC32C checksum does
306+
/// not match the data.
306307
TEST_F(ObjectChecksumIntegrationTest, WriteObjectWithIncorrectChecksumValue) {
307308
auto client = MakeIntegrationTestClient();
308309
auto object_name = MakeRandomObjectName();
309310
auto content = LoremIpsum();
310311

311-
auto bad_crc32c = ComputeCrc32cChecksum("this is not the data being uploaded");
312+
auto bad_crc32c =
313+
ComputeCrc32cChecksum("this is not the data being uploaded");
312314

313315
auto os = client.WriteObject(bucket_name_, object_name,
314316
Crc32cChecksumValue(bad_crc32c),
315-
DisableMD5Hash(true),
316-
IfGenerationMatch(0));
317-
317+
DisableMD5Hash(true), IfGenerationMatch(0));
318+
318319
os << content;
319320
os.Close();
320321
EXPECT_TRUE(os.bad());
321322
auto meta = os.metadata();
322323
EXPECT_THAT(meta, Not(IsOk()));
323-
324-
// The server returns FAILED_PRECONDITION (412) for checksum mismatches during finalization
324+
325+
// The server returns FAILED_PRECONDITION (412) for checksum mismatches during
326+
// finalization
325327
EXPECT_THAT(meta, StatusIs(StatusCode::kFailedPrecondition));
326328
}
327329

@@ -421,4 +423,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
421423
} // namespace storage
422424
} // namespace cloud
423425
} // namespace google
424-

0 commit comments

Comments
 (0)