summaryrefslogtreecommitdiffstats
path: root/tools
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 /tools
parenta1b2010ce87bd878f78acf01a5677875f34254ef (diff)
Merge "buffered" calculateHash function and reuse.
Change-Id: I294038888bd47a139b8c3df68e298e66e5ec2202 Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/common/repositorygen.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/tools/common/repositorygen.cpp b/tools/common/repositorygen.cpp
index dadb651f2..0f49466f3 100644
--- a/tools/common/repositorygen.cpp
+++ b/tools/common/repositorygen.cpp
@@ -36,10 +36,10 @@
#include <lib7z_facade.h>
#include <settings.h>
#include <qinstallerglobal.h>
+#include <utils.h>
#include <kdupdater.h>
-#include <QtCore/QCryptographicHash>
#include <QtCore/QDirIterator>
#include <QtScript/QScriptEngine>
@@ -541,8 +541,7 @@ void QInstallerTools::compressMetaDirectories(const QString &repoDir, const QStr
QFile tmp(tmpTarget);
tmp.open(QFile::ReadOnly);
- QByteArray fileToCheck = tmp.readAll();
- QByteArray sha1Sum = QCryptographicHash::hash(fileToCheck, QCryptographicHash::Sha1);
+ const QByteArray sha1Sum = QInstaller::calculateHash(&tmp, QCryptographicHash::Sha1);
writeSHA1ToNodeWithName(doc, elements, sha1Sum, path);
const QString finalTarget = absPath + QLatin1String("/") + fn;
if (!tmp.rename(finalTarget))
@@ -615,12 +614,11 @@ void QInstallerTools::copyComponentData(const QString &packageDir, const QString
try {
QInstaller::openForRead(&archiveFile, archiveFile.fileName());
- const QByteArray archiveData = archiveFile.readAll();
+ const QByteArray hashOfArchiveData = QInstaller::calculateHash(&archiveFile,
+ QCryptographicHash::Sha1).toHex();
archiveFile.close();
QInstaller::openForWrite(&archiveHashFile, archiveHashFile.fileName());
- const QByteArray hashOfArchiveData = QCryptographicHash::hash(archiveData,
- QCryptographicHash::Sha1).toHex();
archiveHashFile.write(hashOfArchiveData);
qDebug() << "Generated sha1 hash:" << hashOfArchiveData;
infos[i].copiedArchives.append(archiveHashFile.fileName());