summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/downloadarchivesjob.cpp
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@nokia.com>2012-09-28 14:46:17 +0200
committerKarsten Heimrich <karsten.heimrich@digia.com>2012-10-01 12:13:06 +0200
commitc8cc7d5b521c29e0968ce11dd9c63de0ce260c49 (patch)
treef5d90f7a7a8daa86848ff1ede9ebc91abbce52aa /src/libs/installer/downloadarchivesjob.cpp
parenta1b2010ce87bd878f78acf01a5677875f34254ef (diff)
Merge "buffered" calculateHash function and reuse.
Change-Id: I294038888bd47a139b8c3df68e298e66e5ec2202 Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
Diffstat (limited to 'src/libs/installer/downloadarchivesjob.cpp')
-rw-r--r--src/libs/installer/downloadarchivesjob.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/libs/installer/downloadarchivesjob.cpp b/src/libs/installer/downloadarchivesjob.cpp
index f33108442..f44c5c1f8 100644
--- a/src/libs/installer/downloadarchivesjob.cpp
+++ b/src/libs/installer/downloadarchivesjob.cpp
@@ -35,6 +35,7 @@
#include "component.h"
#include "messageboxhandler.h"
#include "packagemanagercore.h"
+#include "utils.h"
#include "kdupdaterfiledownloader.h"
#include "kdupdaterfiledownloaderfactory.h"
@@ -227,16 +228,8 @@ void DownloadArchivesJob::registerFile()
if (m_core->testChecksum()) {
QFile archiveFile(tempFile);
if (archiveFile.open(QFile::ReadOnly)) {
- static QByteArray buffer(1024 * 1024, '\0');
- QCryptographicHash hash(QCryptographicHash::Sha1);
- while (true) {
- const qint64 numRead = archiveFile.read(buffer.data(), buffer.size());
- if (numRead <= 0)
- break;
- hash.addData(buffer.constData(), numRead);
- }
-
- const QByteArray archiveHash = hash.result().toHex();
+ const QByteArray archiveHash = QInstaller::calculateHash(&archiveFile, QCryptographicHash::Sha1)
+ .toHex();
if ((archiveHash != m_currentHash) && (!m_canceled)) {
//TODO: Maybe we should try to download the file again automatically
const QMessageBox::Button res =