From c8cc7d5b521c29e0968ce11dd9c63de0ce260c49 Mon Sep 17 00:00:00 2001 From: kh1 Date: Fri, 28 Sep 2012 14:46:17 +0200 Subject: Merge "buffered" calculateHash function and reuse. Change-Id: I294038888bd47a139b8c3df68e298e66e5ec2202 Reviewed-by: Tim Jenssen --- tools/common/repositorygen.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'tools/common/repositorygen.cpp') 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 #include #include +#include #include -#include #include #include @@ -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()); -- cgit v1.2.3