diff options
author | Katja Marttila <katja.marttila@qt.io> | 2024-04-19 14:22:51 +0300 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2024-04-22 12:56:49 +0300 |
commit | f9e3e9fa91eb004a6b744a212b515397def1c10f (patch) | |
tree | 9eee47c4c3eba9b5eecfe6553f34c00dbf77bd0c /src/libs/installer | |
parent | 31fc0eb9a715a8de08085621a92b09ce878a74b5 (diff) |
Fix metadata fetch in updater mode
If no component is given to update command, look for updates from all
categories so no update is missed. If component is given, utilize the
meta fetch from default repositories first. Checkupdates command
searches update from all categories.
Change-Id: I6dbd9f130c9b008cb066ad7767d2b9a287ecac9f
Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'src/libs/installer')
-rw-r--r-- | src/libs/installer/metadatajob.cpp | 6 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore.cpp | 38 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore.h | 1 |
3 files changed, 33 insertions, 12 deletions
diff --git a/src/libs/installer/metadatajob.cpp b/src/libs/installer/metadatajob.cpp index dd222dd92..1bed304c6 100644 --- a/src/libs/installer/metadatajob.cpp +++ b/src/libs/installer/metadatajob.cpp @@ -142,9 +142,6 @@ QList<Metadata *> MetadataJob::metadata() const QHash<RepositoryCategory, QSet<Repository>>::const_iterator it; for (it = repositoryHash.constBegin(); it != repositoryHash.constEnd(); ++it) { - if (m_core->isUpdater()) - return true; - if (!it.key().isEnabled()) continue; // Let's try the next one @@ -1024,9 +1021,8 @@ QSet<Repository> MetadataJob::getRepositories() // Fetch repositories under archive which are selected in UI. // If repository is already fetched, do not fetch it again. - // In updater mode, fetch always all archive repositories to get updates for (const RepositoryCategory &repositoryCategory : m_core->settings().repositoryCategories()) { - if (!m_core->isUpdater() && !repositoryCategory.isEnabled()) + if (!repositoryCategory.isEnabled()) continue; for (const Repository &repository : repositoryCategory.repositories()) { diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 3f2686efd..f1dec9b8f 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -2936,6 +2936,25 @@ void PackageManagerCore::listInstalledPackages(const QString ®exp) LoggingHandler::instance().printLocalPackageInformation(packages); } +PackageManagerCore::Status PackageManagerCore::searchAvailableUpdates() +{ + setUpdater(); + d->enableAllCategories(); + if (!fetchRemotePackagesTree()) { + qCWarning(QInstaller::lcInstallerInstallLog) << error(); + return status(); + } + + const QList<QInstaller::Component *> availableUpdates = + components(QInstaller::PackageManagerCore::ComponentType::Root); + if (availableUpdates.isEmpty()) { + qCWarning(QInstaller::lcInstallerInstallLog) << "There are currently no updates available."; + return status(); + } + QInstaller::LoggingHandler::instance().printUpdateInformation(availableUpdates); + return status(); +} + /*! Updates the selected components \a componentsToUpdate without GUI. If essential components are found, then only those will be updated. @@ -2947,14 +2966,19 @@ PackageManagerCore::Status PackageManagerCore::updateComponentsSilently(const QS ComponentModel *model = updaterComponentModel(); - bool fallbackReposFetched = false; - bool packagesFound = fetchPackagesWithFallbackRepositories(componentsToUpdate, fallbackReposFetched); + if (componentsToUpdate.isEmpty()) { + d->enableAllCategories(); + fetchRemotePackagesTree(); + } else { + bool fallbackReposFetched = false; + bool packagesFound = fetchPackagesWithFallbackRepositories(componentsToUpdate, fallbackReposFetched); - if (!packagesFound) { - qCDebug(QInstaller::lcInstallerInstallLog).noquote().nospace() - << "No components available for update with the current selection."; - d->setStatus(Canceled); - return status(); + if (!packagesFound) { + qCDebug(QInstaller::lcInstallerInstallLog).noquote().nospace() + << "No components available for update with the current selection."; + d->setStatus(Canceled); + return status(); + } } // List contains components containing update, if essential found contains only essential component diff --git a/src/libs/installer/packagemanagercore.h b/src/libs/installer/packagemanagercore.h index 97f80416a..170ddf557 100644 --- a/src/libs/installer/packagemanagercore.h +++ b/src/libs/installer/packagemanagercore.h @@ -293,6 +293,7 @@ public: const QHash<QString, QString> &filters = QHash<QString, QString>()); bool listAvailableAliases(const QString ®exp = QString()); + PackageManagerCore::Status searchAvailableUpdates(); PackageManagerCore::Status updateComponentsSilently(const QStringList &componentsToUpdate); PackageManagerCore::Status installSelectedComponentsSilently(const QStringList& components); PackageManagerCore::Status installDefaultComponentsSilently(); |