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

View File

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

View File

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