From: APTX Date: Sat, 18 Feb 2012 15:36:48 +0000 (+0100) Subject: ed2k hashing changes for edge cases. X-Git-Url: https://gitweb.tyo.aptx.org/?a=commitdiff_plain;h=47ab9c384b9a36f7376b8225839effdfc7841b99;p=anidbudpclient.git ed2k hashing changes for edge cases. --- 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;