From: Yosuke Matsumura Date: Tue, 8 Apr 2025 15:28:41 +0000 (-0700) Subject: [PATCH] Improvements to the reliability of auto updates X-Git-Tag: archive/raspbian/6.3.6-1+rpi1^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5bb5448552c4167da5eff8dff7cb9ee1e51f6d2a;p=plasma-discover.git [PATCH] Improvements to the reliability of auto updates Adding a wait to refreshUnattended to allow for modules to perform update checks Change refreshUnattended to use lastUnattendedTrigger instead of lastNotificationTime as basis of determining whether to run. BUG: 447245 Gbp-Pq: Name upstream_af0084b6_Improvements-to-the-reliability-of-auto-updates.patch --- diff --git a/notifier/DiscoverNotifier.cpp b/notifier/DiscoverNotifier.cpp index 6ca1a39..ba4ae34 100644 --- a/notifier/DiscoverNotifier.cpp +++ b/notifier/DiscoverNotifier.cpp @@ -135,24 +135,33 @@ void DiscoverNotifier::showDiscoverUpdates(const QString &xdgActivationToken) } } -bool DiscoverNotifier::notifyAboutUpdates() const +bool DiscoverNotifier::checkTriggerTimes(const QDateTime &lastTriggerTime) const { if (state() != NormalUpdates && state() != SecurityUpdates) { // it's not very helpful to notify that everything is in order - qCDebug(NOTIFIER) << "Not notifying about updates, state is" << state(); + qCDebug(NOTIFIER) << "Not triggering, state is" << state(); return false; } if (m_settings->requiredNotificationInterval() < 0) { - qCDebug(NOTIFIER) << "Not notifying about updates, requiredNotificationInterval is" << m_settings->requiredNotificationInterval(); + qCDebug(NOTIFIER) << "Not triggering, requiredNotificationInterval is" << m_settings->requiredNotificationInterval(); return false; } // To configure to a random value, execute: // kwriteconfig5 --file PlasmaDiscoverUpdates --group Global --key RequiredNotificationInterval 3600 - const QDateTime earliestNextNotificationTime = m_settings->lastNotificationTime().addSecs(m_settings->requiredNotificationInterval()); - if (earliestNextNotificationTime.isValid() && earliestNextNotificationTime > QDateTime::currentDateTimeUtc()) { - qCDebug(NOTIFIER) << "Not notifying about updates, earliestNextNotificationTime is" << earliestNextNotificationTime; + const QDateTime earliestNextTriggerTime = lastTriggerTime.addSecs(m_settings->requiredNotificationInterval()); + if (earliestNextTriggerTime.isValid() && earliestNextTriggerTime > QDateTime::currentDateTimeUtc()) { + qCDebug(NOTIFIER) << "Not triggering, earliestNextTriggerTime is" << earliestNextTriggerTime; + return false; + } + + return true; +} + +bool DiscoverNotifier::notifyAboutUpdates() const +{ + if (!checkTriggerTimes(m_settings->lastNotificationTime())) { return false; } @@ -166,6 +175,19 @@ bool DiscoverNotifier::notifyAboutUpdates() const return true; } +bool DiscoverNotifier::proceedUnattended() const +{ + if (!checkTriggerTimes(m_settings->lastUnattendedTrigger())) { + return false; + } + + if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.discover"))) { + qCDebug(NOTIFIER) << "Not proceeding with unattended update, discover is running"; + return false; + } + return true; +} + void DiscoverNotifier::showUpdatesNotification() { if (m_updatesAvailableNotification) { @@ -240,7 +262,7 @@ void DiscoverNotifier::refreshUnattended() { m_settings->read(); - if (!notifyAboutUpdates()) { + if (!proceedUnattended()) { qCDebug(NOTIFIER) << "refreshUnattended: not notifying about updates"; return; } @@ -321,7 +343,7 @@ void DiscoverNotifier::recheckSystemUpdateNeeded() for (BackendNotifierModule *module : std::as_const(m_backends)) module->recheckSystemUpdateNeeded(); - refreshUnattended(); + QTimer::singleShot(20000, this, &DiscoverNotifier::refreshUnattended); } QStringList DiscoverNotifier::loadedModules() const diff --git a/notifier/DiscoverNotifier.h b/notifier/DiscoverNotifier.h index 734abab..47d251e 100644 --- a/notifier/DiscoverNotifier.h +++ b/notifier/DiscoverNotifier.h @@ -91,7 +91,9 @@ private: void updateStatusNotifier(); void refreshUnattended(); + bool checkTriggerTimes(const QDateTime &lastTriggerTime) const; bool notifyAboutUpdates() const; + bool proceedUnattended() const; QList m_backends; QTimer m_timer;