Don't write final block(s) if we already have.

This commit is contained in:
Felix Geyer
2015-07-20 21:02:57 +02:00
parent 61503a8047
commit abe5e8ecea
3 changed files with 27 additions and 12 deletions

View File

@@ -54,7 +54,9 @@ void HashedBlockStream::init()
bool HashedBlockStream::reset()
{
if (isWritable()) {
// Write final block(s) only if device is writable and we haven't
// already written a final block.
if (isWritable() && (!m_buffer.isEmpty() || m_blockIndex != 0)) {
if (!m_buffer.isEmpty()) {
if (!writeHashedBlock()) {
return false;
@@ -74,7 +76,9 @@ bool HashedBlockStream::reset()
void HashedBlockStream::close()
{
if (isWritable()) {
// Write final block(s) only if device is writable and we haven't
// already written a final block.
if (isWritable() && (!m_buffer.isEmpty() || m_blockIndex != 0)) {
if (!m_buffer.isEmpty()) {
writeHashedBlock();
}