@@ -144,22 +144,26 @@ 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+ }
147153
148154 // After this point the session will be closed, and no more calls to the hash
149155 // function are possible.
150156 auto upload_request = UploadChunkRequest (upload_id_, committed_size_,
151157 {ConstBuffer (pbase (), actual_size)},
152- hash_function_, known_hashes_ );
158+ hash_function_, final_hashes );
153159 request_.ForEachOption (internal::CopyCommonOptions (upload_request));
154160 OptionsSpan const span (span_options_);
155161 auto response = connection_->UploadChunk (upload_request);
156162 if (!response) {
157163 last_status_ = std::move (response).status ();
158164 return ;
159165 }
160-
161- auto function = std::move (hash_function_);
162- hash_values_ = std::move (*function).Finish ();
166+ hash_values_ = final_hashes;
163167
164168 committed_size_ = response->committed_size .value_or (0 );
165169 metadata_ = std::move (response->payload );
@@ -203,6 +207,9 @@ void ObjectWriteStreambuf::FlushRoundChunk(ConstBufferSequence buffers) {
203207 auto upload_request =
204208 UploadChunkRequest (upload_id_, committed_size_, payload, hash_function_);
205209 request_.ForEachOption (internal::CopyCommonOptions (upload_request));
210+ upload_request.ForEachOption ([](auto const & opt) {
211+ std::cout << " DEBUG: option=" << opt << " \n " ;
212+ });
206213 OptionsSpan const span (span_options_);
207214 auto response = connection_->UploadChunk (upload_request);
208215 if (!response) {
0 commit comments