Commit 58b0b9ee authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Nate Graham
Browse files

updates: Do not reboot if one of the update transactions failed

It gives the user the chance to see what went down.

BUG: 453250
(cherry picked from commit e6db01be)
parent 66ddd632
Pipeline #173935 passed with stage
in 1 minute and 55 seconds
......@@ -467,7 +467,7 @@ DiscoverPage
PropertyChanges { target: statusLabel; opacity: 1 }
PropertyChanges { target: restartButton; visible: true }
StateChangeScript {
script: if (rebootAtEnd.checked) {
script: if (rebootAtEnd.checked && resourcesUpdatesModel.readyToReboot) {
app.rebootNow()
}
}
......
......@@ -476,6 +476,7 @@ void PackageKitUpdater::finished(PackageKit::Transaction::Exit exit, uint /*time
if (useOfflineUpdates() && exit == PackageKit::Transaction::ExitSuccess) {
PackageKit::Daemon::global()->offline()->trigger(PackageKit::Offline::ActionReboot);
enableReadyToReboot();
}
}
......
......@@ -35,11 +35,21 @@ void AbstractBackendUpdater::enableNeedsReboot()
Q_EMIT needsRebootChanged();
}
void AbstractBackendUpdater::enableReadyToReboot()
{
m_readyToReboot = true;
}
bool AbstractBackendUpdater::needsReboot() const
{
return m_needsReboot;
}
bool AbstractBackendUpdater::isReadyToReboot() const
{
return m_readyToReboot;
}
void AbstractBackendUpdater::setOfflineUpdates(bool useOfflineUpdates)
{
Q_UNUSED(useOfflineUpdates);
......
......@@ -124,7 +124,9 @@ public:
virtual quint64 downloadSpeed() const = 0;
void enableNeedsReboot();
void enableReadyToReboot();
bool isReadyToReboot() const;
bool needsReboot() const;
virtual void setOfflineUpdates(bool useOfflineUpdates);
......@@ -218,6 +220,7 @@ Q_SIGNALS:
private:
bool m_needsReboot = false;
bool m_readyToReboot = false;
};
#endif // ABSTRACTBACKENDUPDATER_H
......@@ -319,6 +319,13 @@ bool ResourcesUpdatesModel::needsReboot() const
return false;
}
bool ResourcesUpdatesModel::readyToReboot() const
{
return kContains(m_updaters, [](AbstractBackendUpdater *updater) {
return !updater->needsReboot() || updater->isReadyToReboot();
});
}
bool ResourcesUpdatesModel::useUnattendedUpdates() const
{
return m_offlineUpdates;
......
......@@ -25,6 +25,7 @@ class DISCOVERCOMMON_EXPORT ResourcesUpdatesModel : public QStandardItemModel
Q_PROPERTY(qint64 secsToLastUpdate READ secsToLastUpdate NOTIFY progressingChanged)
Q_PROPERTY(Transaction *transaction READ transaction NOTIFY progressingChanged)
Q_PROPERTY(bool needsReboot READ needsReboot NOTIFY needsRebootChanged)
Q_PROPERTY(bool readyToReboot READ readyToReboot)
Q_PROPERTY(bool useUnattendedUpdates READ useUnattendedUpdates NOTIFY useUnattendedUpdatesChanged)
public:
explicit ResourcesUpdatesModel(QObject *parent = nullptr);
......@@ -46,6 +47,7 @@ public:
}
Transaction *transaction() const;
bool needsReboot() const;
bool readyToReboot() const;
bool useUnattendedUpdates() const;
Q_SIGNALS:
......
......@@ -132,11 +132,15 @@ void StandardBackendUpdater::transactionRemoved(Transaction *t)
}
const bool found = fromOurBackend && m_pendingResources.remove(t->resource());
m_anyTransactionFailed |= t->status() != Transaction::DoneStatus;
if (found && !m_settingUp) {
refreshProgress();
if (m_pendingResources.isEmpty()) {
cleanup();
if (needsReboot() && !m_anyTransactionFailed) {
enableReadyToReboot();
}
}
}
refreshUpdateable();
......
......@@ -66,6 +66,7 @@ private:
QDateTime m_lastUpdate;
QTimer m_timer;
bool m_canCancel = false;
bool m_anyTransactionFailed = false;
};
#endif // STANDARDBACKENDUPDATER_H
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