From 47ab9c384b9a36f7376b8225839effdfc7841b99 Mon Sep 17 00:00:00 2001 From: APTX Date: Sat, 18 Feb 2012 16:36:48 +0100 Subject: [PATCH] ed2k hashing changes for edge cases. --- hashconsumer.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hashconsumer.cpp b/hashconsumer.cpp index ce383ec..7ef292a 100644 --- a/hashconsumer.cpp +++ b/hashconsumer.cpp @@ -58,13 +58,23 @@ qDebug() << "Thread consumer id is: " << QThread::currentThreadId(); while (!(buffer->get(&data) || abort)); - hash.addData(QCryptographicHash::hash(data, QCryptographicHash::Md4)); + // If file is one chunk don't hash it twice + if (totalSize < ED2K_PART_SIZE) + hash.addData(data); + else + hash.addData(QCryptographicHash::hash(data, QCryptographicHash::Md4)); read += data.size(); emit progress(read, totalSize); } buffer->reset(); + // The "red" ed2k hash + if (totalSize % ED2K_PART_SIZE == 0) + { + hash.addData(QCryptographicHash::hash(QByteArray(), QCryptographicHash::Md4)); + } + if (abort) return; -- 2.52.0