Possibly better fix.

This commit is contained in:
Vladimir Chebotarev 2020-09-30 16:24:36 +03:00
parent b460024356
commit 0497ce4f9c
3 changed files with 20 additions and 11 deletions

View File

@ -56,7 +56,6 @@ WriteBufferFromS3::WriteBufferFromS3(
initiate(); initiate();
} }
void WriteBufferFromS3::nextImpl() void WriteBufferFromS3::nextImpl()
{ {
if (!offset()) if (!offset())
@ -79,23 +78,31 @@ void WriteBufferFromS3::nextImpl()
} }
} }
void WriteBufferFromS3::finalize() void WriteBufferFromS3::finalize()
{ {
next(); finalizeImpl();
if (is_multipart)
writePart(temporary_buffer->str());
complete();
} }
void WriteBufferFromS3::finalizeImpl()
{
if (!finalized)
{
next();
if (is_multipart)
writePart(temporary_buffer->str());
complete();
finalized = true;
}
}
WriteBufferFromS3::~WriteBufferFromS3() WriteBufferFromS3::~WriteBufferFromS3()
{ {
try try
{ {
next(); finalizeImpl();
} }
catch (...) catch (...)
{ {
@ -103,7 +110,6 @@ WriteBufferFromS3::~WriteBufferFromS3()
} }
} }
void WriteBufferFromS3::initiate() void WriteBufferFromS3::initiate()
{ {
Aws::S3::Model::CreateMultipartUploadRequest req; Aws::S3::Model::CreateMultipartUploadRequest req;

View File

@ -57,9 +57,13 @@ public:
~WriteBufferFromS3() override; ~WriteBufferFromS3() override;
private: private:
bool finalized = false;
void initiate(); void initiate();
void writePart(const String & data); void writePart(const String & data);
void complete(); void complete();
void finalizeImpl();
}; };
} }

View File

@ -116,7 +116,6 @@ void ZlibDeflatingWriteBuffer::finish()
if (rc == Z_STREAM_END) if (rc == Z_STREAM_END)
{ {
out->finalize();
finished = true; finished = true;
return; return;
} }