Commit 0f7d0ee3 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

pk: make sense of the pk install code

Only install the application once if there's addons.
Use resourceByPackageName.
parent 9d5fa1b2
......@@ -516,28 +516,19 @@ int PackageKitBackend::updatesCount() const
Transaction* PackageKitBackend::installApplication(AbstractResource* app, const AddonList& addons)
Transaction* t = nullptr;
QVector<AbstractResource*> appsToInstall;
if(!addons.addonsToInstall().isEmpty()) {
QVector<AbstractResource*> appsToInstall = resourcesByPackageNames<QVector<AbstractResource*>>(addons.addonsToInstall());
appsToInstall << app;
foreach(const QString& toInstall, addons.addonsToInstall()) {
appsToInstall += m_packages.packages.value(toInstall);
t = new PKTransaction(appsToInstall, Transaction::ChangeAddonsRole);
} else if (!app->isInstalled())
t = installApplication(app);
if (!addons.addonsToRemove().isEmpty()) {
QVector<AbstractResource*> appsToRemove = kTransform<QVector<AbstractResource*>>(addons.addonsToRemove(), [this](const QString& toRemove){ return m_packages.packages.value(toRemove); });
const auto appsToRemove = resourcesByPackageNames<QVector<AbstractResource*>>(addons.addonsToRemove());
t = new PKTransaction(appsToRemove, Transaction::RemoveRole);
if (!app->isInstalled())
t = installApplication(app);
return t;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment