From a2ded4f5d94c39c8788842fa852eeaffff36a045 Mon Sep 17 00:00:00 2001 From: kh1 Date: Thu, 13 Nov 2014 13:22:01 +0100 Subject: [PATCH] Be a bit smarter while reporting partly progress information. Change-Id: I1eb85e54dc183fbaf6223a113762d38bc67fe8a3 Reviewed-by: Niels Weber --- .../createlocalrepositoryoperation.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/libs/installer/createlocalrepositoryoperation.cpp b/src/libs/installer/createlocalrepositoryoperation.cpp index f3db5f9e..88afd811 100644 --- a/src/libs/installer/createlocalrepositoryoperation.cpp +++ b/src/libs/installer/createlocalrepositoryoperation.cpp @@ -221,7 +221,7 @@ bool CreateLocalRepositoryOperation::performOperation() throw QInstaller::Error(tr("Could not read: %1. Error: %2").arg(updatesXml.fileName(), error)); // build for each available package a name - version mapping - QHash versionMap; + QHash nameVersionHash; const QDomElement root = doc.documentElement(); const QDomNodeList rootChildNodes = root.childNodes(); for (int i = 0; i < rootChildNodes.count(); ++i) { @@ -240,7 +240,7 @@ bool CreateLocalRepositoryOperation::performOperation() version = e.text(); } if (ProductKeyCheck::instance()->isValidPackage(name)) - versionMap.insert(name, version); + nameVersionHash.insert(name, version); } } @@ -256,19 +256,22 @@ bool CreateLocalRepositoryOperation::performOperation() ResourceCollectionManager manager; BinaryContent::readBinaryContent(&file, 0, &manager, 0, BinaryContent::MagicCookie); - emit progressChanged(0.75); + emit progressChanged(0.65); QDir repo(repoPath); - if (!versionMap.isEmpty()) { + if (!nameVersionHash.isEmpty()) { // extract meta and binary data - foreach (const QString &name, versionMap.keys()) { + + const QStringList names = nameVersionHash.keys(); + for (int i = 0; i < names.count(); ++i) { + const QString name = names.at(i); if (!repo.mkpath(name)) { throw QInstaller::Error(tr("Could not create target dir: %1.") .arg(repo.filePath(name))); } // zip the meta files that come with the offline installer helper.m_files.prepend(Static::createArchive(repoPath, - repo.filePath(name), versionMap.value(name), &helper)); + repo.filePath(name), nameVersionHash.value(name), &helper)); emit outputTextChanged(helper.m_files.first()); // copy the 7z files that are inside the component index into the target @@ -288,9 +291,12 @@ bool CreateLocalRepositoryOperation::performOperation() if (!isOpen) // If we reach that point, either the resource was opened already. resource->close(); // or we did open it and have to close it again. } + emit progressChanged(.65f + ((double(i) / double(name.count())) * .25f)); } } + emit progressChanged(0.95); + try { // remove these, if we fail it doesn't hurt Static::removeDirectory(QDir::cleanPath(repoPath + QLatin1String("/installer-config")),