diff options
-rw-r--r-- | src/libs/installer/createlocalrepositoryoperation.cpp | 42 | ||||
-rw-r--r-- | tools/devtool/binarydump.cpp | 16 |
2 files changed, 22 insertions, 36 deletions
diff --git a/src/libs/installer/createlocalrepositoryoperation.cpp b/src/libs/installer/createlocalrepositoryoperation.cpp index 53ca90eec..f3db5f9eb 100644 --- a/src/libs/installer/createlocalrepositoryoperation.cpp +++ b/src/libs/installer/createlocalrepositoryoperation.cpp @@ -256,28 +256,29 @@ bool CreateLocalRepositoryOperation::performOperation() ResourceCollectionManager manager; BinaryContent::readBinaryContent(&file, 0, &manager, 0, BinaryContent::MagicCookie); - QDirIterator it(repoPath, QDirIterator::Subdirectories); - while (it.hasNext() && !it.next().isEmpty()) { - if (it.fileInfo().isDir()) { - const QString fileName = it.fileName(); - const QString absoluteTargetPath = QDir(repoPath).absoluteFilePath(fileName); + emit progressChanged(0.75); - // zip the meta files that come with the offline installer - if (versionMap.contains(fileName)) { - helper.m_files.prepend(Static::createArchive(repoPath, absoluteTargetPath, - versionMap.value(fileName), &helper)); - versionMap.remove(fileName); - emit outputTextChanged(helper.m_files.first()); + QDir repo(repoPath); + if (!versionMap.isEmpty()) { + // extract meta and binary data + foreach (const QString &name, versionMap.keys()) { + 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)); + emit outputTextChanged(helper.m_files.first()); // copy the 7z files that are inside the component index into the target - const ResourceCollection collection = manager.collectionByName(fileName.toUtf8()); + const ResourceCollection collection = manager.collectionByName(name.toUtf8()); foreach (const QSharedPointer<Resource> &resource, collection.resources()) { const bool isOpen = resource->isOpen(); if ((!isOpen) && (!resource->open())) continue; - QFile target(absoluteTargetPath + QDir::separator() + QFile target(repo.filePath(name) + QDir::separator() + QString::fromUtf8(resource->name())); QInstaller::openForWrite(&target); resource->copyData(&target); @@ -290,21 +291,6 @@ bool CreateLocalRepositoryOperation::performOperation() } } - emit progressChanged(0.75); - - QDir repo(repoPath); - if (!versionMap.isEmpty()) { - // offline installers might miss possible old components - foreach (const QString &dir, versionMap.keys()) { - const QString missingDir = repoPath + dir; - if (!repo.mkpath(missingDir)) - throw QInstaller::Error(tr("Could not create target dir: %1.").arg(missingDir)); - helper.m_files.prepend(Static::createArchive(repoPath, missingDir, versionMap.value(dir) - , &helper)); - emit outputTextChanged(helper.m_files.first()); - } - } - try { // remove these, if we fail it doesn't hurt Static::removeDirectory(QDir::cleanPath(repoPath + QLatin1String("/installer-config")), diff --git a/tools/devtool/binarydump.cpp b/tools/devtool/binarydump.cpp index 0952c92a4..046d41d25 100644 --- a/tools/devtool/binarydump.cpp +++ b/tools/devtool/binarydump.cpp @@ -108,22 +108,22 @@ int BinaryDump::dump(const QInstaller::ResourceCollectionManager &manager, const } } - QDirIterator it(targetDir, QDirIterator::Subdirectories); - while (it.hasNext() && !it.next().isEmpty()) { - if (!it.fileInfo().isDir()) - continue; - - const QString fileName = it.fileName(); - const QInstaller::ResourceCollection c = manager.collectionByName(fileName.toUtf8()); + foreach (const QString &name, versionMap.keys()) { + const QInstaller::ResourceCollection c = manager.collectionByName(name.toUtf8()); if (c.resources().count() <= 0) continue; + if (!targetDir.mkpath(name)) { + throw QInstaller::Error(QString::fromLatin1("Could not create target dir: %1.") + .arg(targetDir.filePath(name))); + } + foreach (const QSharedPointer<QInstaller::Resource> &resource, c.resources()) { const bool isOpen = resource->isOpen(); if ((!isOpen) && (!resource->open())) continue; // TODO: should we throw here? - QFile target(targetDir.filePath(fileName) + QDir::separator() + QFile target(targetDir.filePath(name) + QDir::separator() + QString::fromUtf8(resource->name())); QInstaller::openForWrite(&target); resource->copyData(&target); // copy the 7z files into the target directory |