summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <[email protected]>2018-05-02 16:56:36 +0200
committerAleix Pol <[email protected]>2018-05-02 16:56:36 +0200
commit2fc8f0c31e764693396d2fe4e764e4b8c7c14cd1 (patch)
treef1a64badca0aa9a0776b8e809a9cf525748cf03b
parent36643a92cd3095d356f846935c67e37db6c45350 (diff)
De-duplicate redundant updates
Count packages, not resources. BUG: 389108
-rw-r--r--libdiscover/UpdateModel/UpdateModel.cpp1
-rw-r--r--libdiscover/backends/PackageKitBackend/PackageKitBackend.cpp12
2 files changed, 11 insertions, 2 deletions
diff --git a/libdiscover/UpdateModel/UpdateModel.cpp b/libdiscover/UpdateModel/UpdateModel.cpp
index 8e7d9bd..1f22913 100644
--- a/libdiscover/UpdateModel/UpdateModel.cpp
+++ b/libdiscover/UpdateModel/UpdateModel.cpp
@@ -262,7 +262,6 @@ int UpdateModel::toUpdateCount() const
int UpdateModel::totalUpdatesCount() const
{
-
int ret = 0;
QSet<QString> packages;
foreach (UpdateItem* item, m_updateItems) {
diff --git a/libdiscover/backends/PackageKitBackend/PackageKitBackend.cpp b/libdiscover/backends/PackageKitBackend/PackageKitBackend.cpp
index f091639..c90fb0f 100644
--- a/libdiscover/backends/PackageKitBackend/PackageKitBackend.cpp
+++ b/libdiscover/backends/PackageKitBackend/PackageKitBackend.cpp
@@ -421,7 +421,17 @@ bool PackageKitBackend::hasSecurityUpdates() const
int PackageKitBackend::updatesCount() const
{
- return upgradeablePackages().count();
+ int ret = 0;
+ QSet<QString> packages;
+ for(auto res: upgradeablePackages()) {
+ const auto packageName = res->packageName();
+ if (packages.contains(packageName)) {
+ continue;
+ }
+ packages.insert(packageName);
+ ret += 1;
+ }
+ return ret;
}
Transaction* PackageKitBackend::installApplication(AbstractResource* app, const AddonList& addons)