Skip to content

Commit 8082b39

Browse files
author
Bret Ambrose
committed
Centralize stream cleanup
1 parent c5d4b14 commit 8082b39

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

aws-cpp-sdk-transfer/include/aws/transfer/TransferHandle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ namespace Aws
330330

331331
private:
332332

333+
void CleanupDownloadStream();
334+
333335
bool m_isMultipart;
334336
Aws::String m_multipartId;
335337
TransferDirection m_direction;

aws-cpp-sdk-transfer/source/transfer/TransferHandle.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,7 @@ namespace Aws
113113

114114
TransferHandle::~TransferHandle()
115115
{
116-
if(m_downloadStream)
117-
{
118-
Aws::Delete(m_downloadStream);
119-
m_downloadStream = nullptr;
120-
}
116+
CleanupDownloadStream();
121117
}
122118

123119
void TransferHandle::ChangePartToCompleted(const PartPointer& partState, const Aws::String &eTag)
@@ -237,11 +233,9 @@ namespace Aws
237233

238234
if (IsFinishedStatus(value))
239235
{
240-
if(m_downloadStream && value == TransferStatus::COMPLETED)
236+
if(value == TransferStatus::COMPLETED)
241237
{
242-
m_downloadStream->flush();
243-
Aws::Delete(m_downloadStream);
244-
m_downloadStream = nullptr;
238+
CleanupDownloadStream();
245239
}
246240

247241
std::unique_lock<std::mutex> semaphoreLock(m_statusLock);
@@ -296,5 +290,15 @@ namespace Aws
296290
{
297291
SetVersionId(downloadConfig.versionId);
298292
}
293+
294+
void TransferHandle::CleanupDownloadStream()
295+
{
296+
if(m_downloadStream)
297+
{
298+
m_downloadStream->flush();
299+
Aws::Delete(m_downloadStream);
300+
m_downloadStream = nullptr;
301+
}
302+
}
299303
}
300304
}

0 commit comments

Comments
 (0)