From dbdf186ac50e42068c71821ae157a43df3438d55 Mon Sep 17 00:00:00 2001 From: Karsten Heimrich Date: Mon, 4 May 2015 14:27:46 +0200 Subject: Fix issue with accessing install target directory. In case we run as installer, do not look into the installation target directory to read the package XML file. This needs only be done to get installed packages, read the application name and version to compare updates and online components against. Change-Id: Ie5b82854e41dc2f11ae5668c5839351c2fc52e04 Reviewed-by: Jarek Kobus Reviewed-by: Karsten Heimrich --- src/libs/installer/packagemanagercore_p.cpp | 48 ++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'src/libs/installer/packagemanagercore_p.cpp') diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 6eb469410..34378fb7a 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -560,13 +560,9 @@ void PackageManagerCorePrivate::initialize(const QHash ¶ms disconnect(this, SIGNAL(uninstallationStarted()), ProgressCoordinator::instance(), SLOT(reset())); connect(this, SIGNAL(uninstallationStarted()), ProgressCoordinator::instance(), SLOT(reset())); - // TODO: We should avoid this in case of installer. - m_packagesInfo->setFileName(componentsXmlPath()); + if (!isInstaller()) + m_packagesInfo->setFileName(componentsXmlPath()); - // Note: force overwriting the application name and version in case we run as installer. - // Both will be set to wrong initial values if we install into an already existing - // installation. This can happen if the components.xml path has not been changed, - // but name or version of the new installer. if (isInstaller() || m_packagesInfo->applicationName().isEmpty()) { // TODO: this seems to be wrong, we should ask for ProductName defaulting to applicationName... m_packagesInfo->setApplicationName(m_data.settings().applicationName()); @@ -2120,28 +2116,32 @@ PackagesList PackageManagerCorePrivate::remotePackages() */ LocalPackagesHash PackageManagerCorePrivate::localInstalledPackages() { - LocalPackagesHash installedPackages; + if (isInstaller()) + return LocalPackagesHash(); - if (!isInstaller()) { - if (!m_packagesInfo->isValid()) { + LocalPackagesHash installedPackages; + if (m_packagesInfo->error() != PackagesInfo::NoError) { + if (m_packagesInfo->fileName().isEmpty()) m_packagesInfo->setFileName(componentsXmlPath()); - if (m_packagesInfo->applicationName().isEmpty()) - m_packagesInfo->setApplicationName(m_data.settings().applicationName()); - if (m_packagesInfo->applicationVersion().isEmpty()) - m_packagesInfo->setApplicationVersion(QLatin1String(QUOTE(IFW_REPOSITORY_FORMAT_VERSION))); - } + else + m_packagesInfo->refresh(); - if (m_packagesInfo->error() != KDUpdater::PackagesInfo::NoError) { - setStatus(PackageManagerCore::Failure, tr("Failure to read packages from: %1.") - .arg(componentsXmlPath())); - } + if (m_packagesInfo->applicationName().isEmpty()) + m_packagesInfo->setApplicationName(m_data.settings().applicationName()); + if (m_packagesInfo->applicationVersion().isEmpty()) + m_packagesInfo->setApplicationVersion(QLatin1String(QUOTE(IFW_REPOSITORY_FORMAT_VERSION))); + } - foreach (const LocalPackage &package, m_packagesInfo->packageInfos()) { - if (statusCanceledOrFailed()) - break; - installedPackages.insert(package.name, package); - } - } + if (m_packagesInfo->error() != PackagesInfo::NoError) { + setStatus(PackageManagerCore::Failure, tr("Failure to read packages from: %1.") + .arg(componentsXmlPath())); + } + + foreach (const LocalPackage &package, m_packagesInfo->packageInfos()) { + if (statusCanceledOrFailed()) + break; + installedPackages.insert(package.name, package); + } return installedPackages; } -- cgit v1.2.3