Commit ee8e4942 authored by Antonio Rojas's avatar Antonio Rojas
Browse files

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 8c5f6df3
......@@ -137,6 +137,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);
......@@ -144,7 +145,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;
......@@ -175,7 +176,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()
......
Supports Markdown
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