Commit c0277f80 authored by Antonio Rojas's avatar Antonio Rojas Committed by Aleix Pol Gonzalez

Abort transaction on PackageKit errors

If PackageKit throws an error, abort the transaction instead of finishing it anyway (potentially breaking the user's installation).
This is far from ideal, but prevents Discover from performing destructive operations while the PackageKit issues are fixed

BUG: 394327
Differential Revision: https://phabricator.kde.org/D13119
parent 256233de
......@@ -134,6 +134,7 @@ void PKTransaction::cleanup(PackageKit::Transaction::Exit exit, uint runtime)
{
Q_UNUSED(runtime)
const bool cancel = !m_proceedFunctions.isEmpty() || exit == PackageKit::Transaction::ExitCancelled;
const bool failed = exit == PackageKit::Transaction::ExitFailed;
const bool simulate = m_trans->transactionFlags() & PackageKit::Transaction::TransactionFlagSimulate;
disconnect(m_trans, nullptr, this, nullptr);
......@@ -141,7 +142,7 @@ void PKTransaction::cleanup(PackageKit::Transaction::Exit exit, uint runtime)
const auto backend = qobject_cast<PackageKitBackend*>(resource()->backend());
if (!cancel && simulate) {
if (!cancel && !failed && simulate) {
auto packagesToRemove = m_newPackageStates.value(PackageKit::Transaction::InfoRemoving);
QMutableListIterator<QString> i(packagesToRemove);
QSet<AbstractResource*> removedResources;
......@@ -172,7 +173,10 @@ void PKTransaction::cleanup(PackageKit::Transaction::Exit exit, uint runtime)
}
this->submitResolve();
setStatus(Transaction::CancelledStatus);
if (failed)
setStatus(Transaction::DoneWithErrorStatus);
else
setStatus(Transaction::CancelledStatus);
}
void PKTransaction::processProceedFunction()
......
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